{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Fa08Final

# Fa08Final - Points off 1 2 3 4 5 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
CS 307 – Final – Fall 2008 2 Consider the following binary tree. M is the root of the tree. M / \ D R / \ / \ A K P T \ Z B. What is the result of a pre-order traversal of the binary tree? C. What is the result of a in-order traversal of the binary tree? D. What is the result of a post-order traversal of the binary tree? E. What is the result of a level-order traversal of the binary tree? F. Is the tree shown above a binary search tree? G. What is the height of the tree shown above? H. What is the worst case Big O for adding N elements, one at a time to an initially empty binary search tree using the traditional, naïve insertion algorithm? I. What is the Big O of the following method? Assume Math.random is O(1). list is initially empty. public void randFill(int N, LinkedList<Double> list ){ assert list.size() == 0; for(int i = 0; i < N; i++) list.add(Math.random()); double total = 0.0; for(int i = 0; i < list.size(); i++) total += list.get(i); } J. What is the Big O of the following method? public ArrayList<Integer> createAndFill(int N){ ArrayList<Integer> result = new ArrayList<Integer>(); for(int i = 0; i < N; i++) result.add(i); return result; }
CS 307 – Final – Fall 2008 3 K. An UnsortedSet class uses a Java ArrayList as its internal storage container.

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 ]}

### Page1 / 18

Fa08Final - Points off 1 2 3 4 5 Total off Net Score CS 307...

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

View Full Document
Ask a homework question - tutors are online