Spring02Final - Points off 1 2 3 4 Admin Total off Net...

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 Admin Total off Net Score CS 307 – Final Exam– Spring 2002 Name____________________________________ Last 4 digits of SSN / Student ID ______________ Class Unique ID ___________________________ Instructions: 1. There are 4 questions on this test. Question 1 is worth 60 points, all others are worth 20 points each. 2. You will have 3 hours to complete the test. 3. You may not use a calculator. 4. When code is required, write Java code. 5. You may not use any classes or methods from the Java Standard Library other than the ones specifically mentioned on each question. 6. The style guide is not in effect. 7. Please make your answers legible. 1. Java mechanics and short answer questions. (2 points each) Write the answer to each question in the space provided. If code results in an error indicate if it is a compile error or runtime error. A. The following numbers are inserted 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. 307 310 108 408 313 336 105 CS 307 – Final Exam – Spring 2002 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.data + " " ); B. What is the output of a preorder traversal of the tree? ____________________________________________________ C. What is the output of a inorder traversal of the tree? ____________________________________________________ D. What is the output of a postorder traversal of the tree? ____________________________________________________ E. Is the tree on page 2 a binary search tree? CS 307 – Final Exam – Spring 2002 2 37 7 101 401 47 13 17 53 29 root of tree
Background image of page 2
______________________ F. Consider inserting 1 item into a binary search tree that contains N nodes. There are no special algorithms to ensure or maintain balance in the tree as items are inserted or deleted. What is the average case Big O for inserting 1 item into the tree? ________________________ G. Consider inserting 1 item into a binary search tree that contains N nodes. There are no special algorithms to ensure or maintain balance in the tree as items are inserted or deleted. What is the worst case Big O for inserting 1 item into the tree? ________________________ H. Consider inserting N items into a binary search tree that is initially empty. There are no special algorithms to ensure or maintain balance in the tree as items are inserted or deleted. What is the average case Big O for inserting N items into the (initially empty) tree? ________________________________________________________ I. Consider inserting N items into a binary search tree that is initially empty. There are no special algorithms to ensure or maintain balance in the tree as items are inserted or deleted. What is the worst case Big O for inserting N items into the (initially empty) tree? ________________________________________________________ J.
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.

Page1 / 15

Spring02Final - Points off 1 2 3 4 Admin Total off Net...

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