Sp09Final - Points off 1 2 3 4 5 Total off Net Score CS 307 Final Spring 2009 Name UTEID login name Instructions 1 2 3 4 5 6 Please turn off your

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 – Spring 2009 2 Consider the following binary tree. A is the root of the tree. A / \ G I / / A S / \ N O 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 best case Big O for the following method? list contains N elements. public int count(int cutoff, LinkedList<Integer> list){ int count = 0; for(int i = 0; i < list.size(); i++){ if( list.get(i) > cutoff ){ count++; } } return count; } H. What is the worst case Big O for adding N elements, one at a time to an initially empty red black tree? I. What is output by the following code? String name = "WILKINSON"; Stack<Character> st = new Stack<Character>(); for(int i = 0; i < name.length(); i++) st.push( name.charAt(i) ); st.pop(); st.pop(); st.push( st.peek() ); // peek returns top item without removing for(int i = 0; i < 4; i++) System.out.print( st.pop() );
CS 307 – Final – Spring 2009 3 J. What is the worst case Big O of the following method? Assume the println method is O(1) and that list contains N elements. public void clearPrint(double cutoff, ArrayList<Double>

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.

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 at Austin.

Page1 / 18

Sp09Final - Points off 1 2 3 4 5 Total off Net Score CS 307 Final Spring 2009 Name UTEID login name Instructions 1 2 3 4 5 6 Please turn off your

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

View Full Document
Ask a homework question - tutors are online