Fa07Final - Points off 1 2 3 4 5 6 Total off Net Score CS...

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

View Full Document Right Arrow Icon
CS 307 – Final – Fall 2007 1 Points off 1 2 3 4 5 6 Total off Net Score CS 307 – Final – Fall 2007 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. 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. 9. 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 1 at a time in the order shown into an initially empty binary search tree using the traditional algorithm. Draw the resulting tree. 16 7 -5 0 25
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 – Fall 2007 2 Consider the following binary tree: 3 / \ 7 8 / / \ 0 5 2 / 1 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? Consider the following Huffman code tree. Characters only exist in nodes that are leaves. Nodes with characters are represented with a dash. '-' - / \ - - / \ / \ - e i h / \ g l E. Given the above Huffman code tree, what is the binary code for the word " lie "? F. What is output by the following code? Stack<Character> s1 = new Stack<Character>(); String name = "isabelle"; for(int i = 0; i < name.length(); i++) if( name.charAt(i) > 'c' ) s1.push( name.charAt(i) ); while( !s1.isEmpty() ) System.out.print( s1.pop() ); G. Consider a linked list that uses singly linked nodes and maintains a reference to the first node and last node in the list. What is the Big O of removing the last element of the list? The list has N elements in it.
Background image of page 2
CS 307 – Final – Fall 2007 3 H. What is the worst case height of a binary search tree that contains N elements and was created using the naïve insertion algorithm. I.
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 / 20

Fa07Final - Points off 1 2 3 4 5 6 Total off Net Score CS...

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