Sp03FinalSolutionAndCriteria

Sp03FinalSolutionAndCriteria - Spring 2003 Final Solution...

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

View Full Document Right Arrow Icon
Spring 2003 Final Solution and Criteria 1. Same as key or -2 (except as noted.) On Big O missing O( ) is okay if function correct. Example, O(N) same as N or linear. A. 101 / \ -12 201 \ 59 / \ 37 91 B. 19 11 7 5 17 113 61 131 151 C. 5 7 11 17 19 61 113 131 151 D. 5 7 17 11 61 151 131 113 19 E. yes F. 13 12 12 G. 3 1 2 4 8 16 H. O(N) I. O(log N) J. N^2 K. O(N^2) L. O(N) M. 2 5 8 11 N. O(N) O. P. O(N), N = number of nodes in tree (-1 for either part missing) Q. O(log N) R. O(N^2) S. 0010 T. O(1)
Background image of page 1

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

View Full DocumentRight Arrow Icon
2. Solution //base case, trees are mirror images, same structure return true; // base case, one root null, other not, -> not mirror images else if ( t1 == null || t2 == null) return false; // recursive step. t1 and t2 might be the mirror images of each other // must check to see that left subtree of t1 is same structure as right of t2 // and right subtree of t1 is same structure as left of t2 are MirrorImages(t1.getRight(), t2.getLeft());
Background image of page 2
3. Solution
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

Sp03FinalSolutionAndCriteria - Spring 2003 Final Solution...

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

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