Sp03FinalSolutionAndCriteria

# Sp03FinalSolutionAndCriteria - Spring 2003 Final Solution...

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

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)

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

View Full Document
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());
3. Solution

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.

### Page1 / 5

Sp03FinalSolutionAndCriteria - Spring 2003 Final Solution...

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

View Full Document
Ask a homework question - tutors are online