fall2004finalsol

fall2004finalsol - 1.00 Introduction to Computers and...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1.00 Introduction to Computers and Engineering Problem Solving Final / December 13, 2004 Name: Email Address: Solution TA: Section: 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. 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 1.00 Final 1/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 F A L S E 4. A method can throw more than one class of Exception . TRUE F A L S E 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 ) 1.00 Final 2/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. 2 1 d.add(3) 3 2 1 d.remove() 3 2 Which type of data structure best describes this data structure? STACK QUEUE 1.00 Final 3/14 Fall 2004 10. Consider following Binary Search Tree. 18 25 11 7 16 19 12 32 17 33 27 8 4 a. Whats the First Key of this Binary Search Tree? Node 4 b. If node 11 was to be deleted from the tree, which node would be the successor that replaces node 11? Node 12 1.00 Final 4/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 the Java Collections Framework LinkedList class that holds only Integer objects and finds the average of contained Integer values. Here is the method signature: public static double findAverage(LinkedList list) For instance, lets suppose you have a LinkedList object that contains Integer(4) , Integer(6) , Integer(3) , Integer(2) , Integer(5) , and Integer(4) . The findAverage() method should find the average of the contained six Integer values (4.0 in this case) and return it....
View Full Document

Page1 / 14

fall2004finalsol - 1.00 Introduction to Computers and...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online