Sp08Final - Points off 1 2 3 4 5 Total off Net Score CS 307...

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

View Full Document Right Arrow Icon
CS 307 – Final – Spring 2008 1 Points off 1 2 3 4 5 Total off Net Score CS 307 – Final – Spring 2008 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. When code is required, write Java code. 6. You may add helper methods if you wish when answering coding questions. 7. When answering coding questions assume the preconditions of the methods are met. 8. There is a quick reference sheet with some of the classes from the Java standard library attached to the test. 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 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 Big O 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 insertion algorithm. Draw the resulting tree. 7 0 -5 5 3
Background image of page 1

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

View Full DocumentRight Arrow Icon
CS 307 – Final – Spring 2008 2 Consider the following binary tree: C / \ A E / / K M \ A / \ J S B. What is the result of a pre-order traversal of the binary tree? C. What is the result of a in-order traversal of the binary tree? D. What is the result of a post-order traversal of the binary tree? E. Is the tree shown above a binary search tree? F. What is the height of the tree shown above? G. What is the average case Big O for adding an element to a Red Black Tree that already contains N elements? H. The following Java code will result in a syntax error. Explain the cause of the syntax error ArrayList list = new ArrayList(); list.add("Texas"); list.add("Nevada"); System.out.println( list.get(1).charAt( 2 ) ); I. The following code attempts to determine if an element is present in a list but has a logic error. Explain what the logic error is. public boolean isPresent(ArrayList<String> list, String tgt){ boolean found = false; Iterator<String> it = list.iterator(); while( it.hasNext() ) found = found || it.next().equals( tgt ); return found; }
Background image of page 2
CS 307 – Final – Spring 2008 3 J. What is the output of the following code?
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the 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.

Page1 / 18

Sp08Final - Points off 1 2 3 4 5 Total off Net Score CS 307...

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

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