This preview shows pages 1–4. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CS 307 Final Fall 2009 1 Points off 1 2 3 4 5 6 Total off Net Score CS 307 Final Fall 2009 Name__________________________________________ UTEID login name _______________________________ Instructions: 1. Please turn off your cell phones. 2. There are 6 questions on this test. 3. You have 3 hours to complete the test. 4. You may not use a calculator on the test. 5. You may add helper methods if you wish when answering coding questions. 6. When answering coding questions assume the preconditions of the methods are met. 1. (1.5 point each, 30 points total) Short answer. Place you answers on the attached answer sheet. For questions that ask what is the output: If the code contains a syntax error or other compile error, answer Compiler error. If the code would result in a runtime error or exception answer Runtime error. If the code results in an infinite loop answer Infinite loop. On questions that ask for the Big O of a method or algorithm, recall that when asked for Big O your answer should be the most restrictive, correct Big O function. For example Selection Sort has an expected case Big O of O(N 2 ), but per the formal definition of Big O it is correct to say Selection Sort also has a Big O of O(N 3 ). Give the most restrictive, correct function. (Closest without going under.) A. The following values are inserted one at a time in the order shown into an initially empty binary search tree using the traditional, nave insertion algorithm. Draw the resulting tree. 72 125 218 6 51 41 CS 307 Final Fall 2009 2 Consider the following binary tree. 12 is the root of the tree. 12 / \ 9 20 / \ \ 0 25 30 / 5 B. What is the result of a preorder traversal of the binary tree shown above? C. What is the result of a inorder traversal of the binary tree shown above? D. What is the result of a postorder traversal of the binary tree above? E. Is the tree shown above a binary search tree? F. On the answer sheet, fill in the nodes of the given binary tree with integer values between 1 and 10 to make the tree shown a binary search tree. G. Explain why the following tree is not a red black tree. The values in each node are integers. The color of the node is below the value. H. Without moving or rotating any nodes is it possible to make the tree part G a red black tree? In other words you can only change the color of nodes. CS 307 Final Fall 2009 3 Consider the following method: public int sumList(List<Integer> list) { int total = 0; for(int i = 0; i < list.size(); i++) total += list.get(i); return total; } I. What is the Big O of method sumList if list is a Java ArrayList ? J. What is the Big O of method sumList if list is a Java LinkedList ?...
View Full
Document
 Spring '08
 SCOTT

Click to edit the document details