Sp04FinalSuggetsedSoln

Sp04FinalSuggetsedSoln - Final Exam Spring 2004. Key 1A 60...

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

View Full Document Right Arrow Icon
Final Exam Spring 2004. Key 1A 60 \ 170 / \ 146 217 / 104 B GHAVANNLEIS C AVHNGELNSI D VANHELSING E 0 0 2 2 4 4 F 5 4 3 2 1 0 G 0 2 1 2 H O(log N) I O(log N) J O(1) K O(N), N = number of nodes in the tree L O(N^2) M O(N) N appropriate drawing O Answers varies but Big O had to match chosen data structure P 63 Q O(N^2) R 1. all ops are O(1) for hashtable O(logN) for BST in ave case 2. can use anything as keys for hashtable, but BST can only use Comparables for keys S. 5 T. So that tha ArrayList can hold any type of Objects (all objects in Java are descendants of the Object class) and thus only have to create the ArrayList 1 time. 2. { helper("", root); } private void helper(String code, HuffNode n) { //base case? System.out.println( n.getChar() + " " + code); else { helper(code + "0", n.getLeft() ); helper(code + "1", n.getRight() ); } }
Background image of page 1

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

View Full DocumentRight Arrow Icon
3A private int iMySize; private ArrayList myKeys; private ArrayList myValues; have two ArrayLists, 1 to hold keys, and the other to hold the values for those
Background image of page 2
Image of page 3
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.

Page1 / 3

Sp04FinalSuggetsedSoln - Final Exam Spring 2004. Key 1A 60...

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

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