Fa05Final - Points off 1 2 3 4 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
Points off 1 2 3 4 Total off Net Score CS 307 – Final – Fall 2005 Name__________________________________________ UTEID login name _______________________________ TA’s Name ___________________________ Instructions: 1. Please turn off your cell phones. 2. There are 4 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 1. (2 points each, 40 points total) Short answer. Place you answers on the attached answer sheet. 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”. Recall that when asked for Big O your answer should be the most precise Big O function. For example Selection Sort has an average 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 precise 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 naïve insertion algorithm.) The tree is initially empty. Draw the resulting tree. 72, 33, 9, 12, 38, 101 CS 307 – Final – Fall 2005 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
For parts B - F 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() + " " ); 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. What is the output of a level order traversal of the above tree? F. Is the binary tree shown above a binary search tree? G. If 1000 elements are inserted into a Binary Search Tree using the naïve insertion algorithm, what is the expected (average case) height of the resulting tree? (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 3.) CS 307 – Final – Fall 2005 2 root of tree 37 13 17 9 77 97 70 75 85
Background image of page 2
Recall the following methods from the ArrayList class: boolean add (Object x) Add x to the end of list. returns true . Object set (int index, Object x) Replaces the element at the specified position in this list with the specified element. void
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 at Austin.

Page1 / 24

Fa05Final - Points off 1 2 3 4 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