{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Fa05Final

# Fa05Final - Points off 1 2 3 4 Total off Net Score CS 307...

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

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

View Full Document
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
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 add (int index, Object x) Inserts x at position index , sliding elements at position index and higher to the right (adds 1 to their indices) and adjusts size Object remove (int index) Removes element from position index , sliding elements at position index + 1 and higher to the left (subtracts 1 from their indices) and adjusts size returns the element formerly at the specified position Object get (int index) return the element at the given index H. What is the output of the following code?

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern