fall2004finalexa

fall2004finalexa - 1.00/1.001 Introduction to Computers and...

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

View Full Document Right Arrow Icon
1.00/1.001 Introduction to Computers and Engineering Problem Solving Final / December 13, 2004 Name: Email Address: 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/1.001 Final 1/14 Fall 2004
Background image of page 1

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

View Full DocumentRight Arrow Icon
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 ) 1.00/1.001 Final 2/14 Fall 2004
Background image of page 2
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 Which type of data structure best describes this data structure? STACK QUEUE d.add(3) 3 2 1 d.remove() 3 2 1.00/1.001 Final 3/14 Fall 2004
Background image of page 3

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

View Full DocumentRight Arrow Icon
10. Consider following Binary Search Tree. 18 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? 25 11 7 16 19 12 32 17 33 27 8 4 1.00/1.001 Final 4/14 Fall 2004
Background image of page 4
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
Background image of page 5

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

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

This note was uploaded on 11/29/2011 for the course CIVIL 1.00 taught by Professor Georgekocur during the Spring '05 term at MIT.

Page1 / 14

fall2004finalexa - 1.00/1.001 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