Sp04Final - Points off 1 2 3 4 Total off Net Score...

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

View Full Document Right Arrow Icon
Points off 1 2 3 4 Total off Net Score Percentage CS 307 – Final – Spring 2004 Name__________________________________________ UTEID login name _______________________________ Section Leader's Name ___________________________ Instructions: 1. There are 4 questions on this test. 2. You have 3 hours to complete the test. 3. You may not use a calculator on the test. 4. When code is required, write Java code. 5. The style guide is not in effect except where noted. 6. Efficiency is not graded except where noted. 7. Ensure your answers are legible. 8. 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. 9. In coding question you may add helper methods if you wish. 1. (2 points each, 40 points total) Short answer. If an error would occur answer "syntax error" or "runtime error" depending on what type of error it would be. 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 also 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. The tree is initially empty. Draw the resulting tree. 60, 170, 146, 217, 104 _____________________________________________________________________________ CS 307 – Final – Spring 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, C, and D 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? ____________________________________________________ CS 307 – Final – Spring 2004 2 root of tree "G" "H" "A" "N" "V" "N" "I" "S" "L" "E"
Background image of page 2
E. Consider a Queue class that holds ints. What is the output of the following code? IntQueue q = new IntQueue(); for(int i = 0; i < 3; i++) q.enqueue( i * 2 ); int limit = q.size(); for(int i = 0; i < limit; i++) { int temp = q.dequeue(); q.enqueue(temp); q.enqueue(temp); } while( !q.isEmpty() ) { System.out.print( q.dequeue() + " " ); } _____________________________________________________________________________ CS 307 – Final – Spring 2004 3
Background image of page 3

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

View Full DocumentRight Arrow Icon
F. Consider a List class that holds ints. void
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 20

Sp04Final - Points off 1 2 3 4 Total off Net Score...

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

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