Fall02FinalKey - Fall 2002 Final Key 1A 195 156 20 162 68...

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

View Full Document Right Arrow Icon
Fall 2002 Final - Key 1A. 195 / \ 156 / \ 20 162 / \ 68 \ 150 B. -42 -5 32 -22 81 135 138 161 C. -5 32 -42 135 81 138 -22 161 D. 32 -5 135 138 82 161 -22 -42 E. No F. O(N) G. O(N^2) H. O(N * logN) I. O(N), As N gets large resizing a lot J. O(1), Resize very infrequently K. O(N^2 * logN) L. 8.5N + 7 or 5/2 * N + 1 M. O(N) N. 48 sec O. 1280 sec P. O(N), must track top or bottom fixed Q. R. some mention of accessing arrays S. O(N), N = number of elements in Set T. 40 2. Clean recursive solution n = helper(n); // note if n is a leaf this won't actually work. Method // would have to return a BTNode to root public BTNode helper(BTNode n) { // n = null -> Base Case, no work if( n != null) { // other base case, n is a leaf n = null; else
Background image of page 1

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

View Full DocumentRight Arrow Icon
{ // recursive step n.setLeft(helper(n.getLeft()); n.setRight(helper(n.getRight()); } } return n; } Not so clean recursive solution { // base case. check to see if n is a leaf if( n != null ) {
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

Fall02FinalKey - Fall 2002 Final Key 1A 195 156 20 162 68...

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