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: Points off 1 2 3 4 5 Total off Net Score CS 307 Final Spring 2006 Name__________________________________________ UTEID login name _______________________________ Circle your TAs name: Chendi Vinod Instructions: 1. Please turn off your cell phones. 2. There are 5 questions on this test. The are 120 points on the test. 3. You have 3 hours to complete the test. 4. You may not use a calculator on the test. 5. When code is required, write Java code. 6. Ensure your answers are legible. 7. You may add helper methods if you wish when answering coding questions. 8. When answering coding questions assume the preconditions of the methods are met. 1. (2 points each, 40 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 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 Big O function. (Closest without going under.) A. The following numbers are inserted, one at a time, in the order shown, into a binary search tree with no checks to ensure or maintain balance. (i.e. the traditional nave insertion algorithm.) The tree is initially empty. Draw the resulting tree. 2, 4, 8, 16, 7 CS 307 Final Spring 2006 1 For parts B  E consider the following binary tree. For each question assume when a node is processed the value in the node is printed out by the statement: System.out.print( currentNode.getData() + &quot; &quot; ); B. What is the output of a preorder traversal of the above tree? C. What is the output of an inorder traversal of the above tree? D. What is the output of a postorder traversal of the above tree? E. Is the binary tree shown above a binary search tree? F. If 1000 elements are inserted one at a time into a binary search tree with no checks to ensure or maintain balance (i.e. the traditional nave insertion algorithm.) what is the worst case height of the resulting tree? The actual number, not a Big O function. (The height of a tree is the number of links from the root to the deepest leaf. The height of the tree on this page is 2.) CS 307 Final Spring 2006 2 root of tree 10 5 39 12 5 51 G. N elements are inserted one at a time into a Red Black tree. What is the worst case Big O of inserting all N items?...
View Full
Document
 Spring '08
 SCOTT

Click to edit the document details