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 – Spring 2010 1 Points off 1 2 3 4 5 Total off Net Score CS 307 – Final – Spring 2010 Name__________________________________________ UTEID login name _______________________________ Instructions: 1. Please turn off your cell phones. 2. There are 5 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, naïve insertion algorithm. Draw the resulting tree. 37 42 13 101 12 CS 307 – Final – Spring 2010 2 Consider the following binary tree. 17 is the root of the tree. 17 / \ 19 20 \ \ 25 30 / / \ 10 7 15 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. What is the result of the following postfix expression? For subtraction the operand closest to the subtraction symbol is the infix equivalent of the right hand side operand. 10 5 11 3  + * H. What is output by the following code? String data = "BINARY"; Stack<Character> st = new Stack<Character>(); for(int i = 0; i < data.length(); i++) st.push( data.charAt(i) ); st.pop(); st.pop(); for(int i = 0; i < 3; i++) System.out.print( st.pop() ); I. What is the Big O of method total ? N = list.size() public int total(LinkedList<Integer> list) { int total = 0; for(int i = 0; i < list.size(); i++) total += list.get(i); return total; } CS 307 – Final – Spring 2010 3 J. What is the worst case Big O of printRev ?...
View
Full
Document
This note was uploaded on 11/30/2010 for the course CS 307 taught by Professor Scott during the Spring '08 term at University of Texas at Austin.
 Spring '08
 SCOTT

Click to edit the document details