Fall09_Final_SuggesteSolution

# Fall09_Final_SuggesteSolution - CS307 Fall 2009 Final Exam...

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

CS307 Fall 2009 Final Exam Suggested Solution and Criteria: 1 1.5 Each A: 72 / \ 6 125 \ \ 51 218 / 41 B: 12, 9, 0, -5, 25, 20, 30 C: -5, 0, 9, 25, 12, 20, 30 D: -5, 0, 25, 9, 30, 20, 12 E: No. F: valid binary search tree using values between 1 and 10. No repeats. G: The path rule is violated OR paths with different numbers of black nodes (1, 2, 3) Or words to that effect. H: Yes. (Explanation not required, but make 200 black, 400 red, and 70 red and magic number is now 2. I: O(N) okay if just N J: O(N^2) okay if N^2 K: Yes, it goes through all of the values in the list using an iterator instead of the get method. (Or words to that effect.) L: O(NlogN) okay if just NlogN or base 2 included M: (3 + 2) * (5 + 2) N: 14 15 1 15 13 O: z s p r s P: Variables must have a box and arrow. Q: 7 bits or just 7 R: Any value between 13 and 25. (10 not okay. That would be best case height which is not likely.) S: add at front, remove from front, or add at end. T: E can be thought of as a variable that stores the data that a particular

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

View Full Document
LinkedList will hold. (or words to that effect)
2. Suggested Solution: Simple version using look ahead: public void split(){ Node<E> temp = first; // if no next, next node, stop while(temp != null && temp.getNext() != null){ temp.setNext( temp.getNext().getNext() ); // skips over odd temp = temp.getNext(); } } // using trailer public void split(){ if(first != null){ Node<E> trail = first; Node<E> lead = first.getNext();

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 / 9

Fall09_Final_SuggesteSolution - CS307 Fall 2009 Final Exam...

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

View Full Document
Ask a homework question - tutors are online