finalv6 - 1.00 Introduction to Computers and Engineering...

Info icon This preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
1.00 Final 1/14 Fall 2004 1.00 Introduction to Computers and Engineering Problem Solving Final / December 13, 2004 Name: Email Address: TA: Section: Question Points Question 1 / 10 Question 2 / 15 Question 3 / 15 Question 4 / 10 Question 5 / 10 Question 6 / 25 Question 7 / 15 Total / 100 You have 180 minutes to complete this exam. For coding questions, you do not need to include comments, and you should assume that all necessary files have already been imported. Good luck.
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
1.00 Final 2/14 Fall 2004 Question 1. True / False + Multiple Choice + Short Answer (10 Points) 1. Every node in a Binary Tree must have 2 children. TRUE FALSE 2. A single stream can be used as both an input stream and an output stream. TRUE FALSE 3. There can be several catch blocks in a single try/catch structure. TRUE FALSE 4. A method can throw more than one class of Exception . TRUE FALSE 5. The following Java source code will compile. public class FinalExam { private int a; public static int printA() { System.out.println(“a = “ + a); } } TRUE FALSE 6. An iterator of a HashMap visits its elements in the order they are inserted. TRUE FALSE 7. Consider a HashTable that does not have any collisions. Suppose there are n items to be stored and m slots in the HashTable . Searching for an element in the HashTable is: a. O ( n ) b. O (1) c. O ( m ) d. O ( log n )
Image of page 2
1.00 Final 3/14 Fall 2004 8. Consider following Java method. public static void findOrder(int n) { int result = 0; for (int i = 0; i < n; i++) { for(int j = i; j < n; j++) { result++; } } } The above code runs in: a. O ( n ) b. O (1) c. O ( n 2 ) d. O ( log n ) 9. Consider an instance of data structure illustrated below. It has an add() method to add an element and remove() method to remove an element. The figure below shows an example of this data structure (referred to as d ) initially, after d.add(3) is called, and after d.remove( ) is called. Which type of data structure best describes this data structure? STACK QUEUE 2 1 d.add(3) 3 2 1 d.remove() 3 2
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
1.00 Final 4/14 Fall 2004 10. Consider following Binary Search Tree. a. What’s the First Key of this Binary Search Tree? b. If node 11 was to be deleted from the tree, which node would be the successor that replaces node 11? 18 11 25 7 16 19 12 17 32 33 27 8 4
Image of page 4
1.00 Final 5/14 Fall 2004 Question 2. LinkedList (15 Points) In this question, you are going to write a static method, findAverage() , which takes an instance of Java Collections Framework LinkedList class that holds only Integer objects and finds the average of contained int values. Here is the method
Image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern