Fa04Final - Points off 1 2 3 4 5 Total off Net Score Exam #...

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 5 Total off Net Score Exam # CS 307 – Final – Fall 2004 Name__________________________________________ UTEID login name _______________________________ Section Leader's 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. The style guide is not in effect except where noted. 7. Efficiency is not graded except where noted. 8. Ensure your answers are legible. 9. When writing code you may not use any methods or classes from the Java Standard Library except as noted and the System.out.print, System.out.println, the equals method, and native arrays of primitives, Strings and other data types allowed by the question. 10. You may add helper methods if you wish when answering coding questions. 11. When answering coding questions assume the preconditions of the methods are met 1. (2 points each, 30 points total) Short answer. Place your answers on the attached answer sheet at the end of the exam. If the code has a syntax error answer syntax error. If the code would result in a runtime error answer runtime error. If the code will not complete due to 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 technically correct to say Selection Sort has a Big O of O(N^3). On this test I want 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 naïve insertion algorithm.) The tree is initially empty. Draw the resulting tree. 32, 5, 4, 74, 31 CS 307 – Final – Fall 2004 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 from parts B, C, and D a binary search tree? CS 307 – Final – Fall 2004 2 root of tree 52 25 9 5 72 75 70 30
Background image of page 2
Consider the following Queue class that holds ints void enqueue (int item) Add this item to the back of the this Queue. The item becomes the last element of the Queue int front ( ) Returns the first element of the Queue, that is the one that has been present the longest. int
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 / 19

Fa04Final - Points off 1 2 3 4 5 Total off Net Score Exam #...

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