{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Sp10Final

# Sp10Final - Points off 1 2 3 4 5 Total off Net Score CS 307...

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

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

View Full Document
CS 307 – Final – Spring 2010 2 Consider the following binary tree. 17 is the root of the tree. 17 / \ 19 20 \ \ 25 30 / / \ 10 7 15 B. What is the result of a pre-order traversal of the binary tree shown above? C. What is the result of a in-order traversal of the binary tree shown above? D. What is the result of a post-order traversal of the binary tree above? E. Is the tree shown above a binary search tree? F. On the answer sheet, fill in the nodes of the given binary tree with integer values between 1 and 10 to make the tree shown a binary search tree. G. What is the result of the following postfix expression? For subtraction the operand closest to the subtraction symbol is the infix equivalent of the right hand side operand. 10 5 11 3 - + * H. What is output by the following code? String data = "BINARY"; Stack<Character> st = new Stack<Character>(); for(int i = 0; i < data.length(); i++) st.push( data.charAt(i) ); st.pop(); st.pop(); for(int i = 0; i < 3; i++) System.out.print( st.pop() ); I. What is the Big O of method total ? N = list.size() public int total(LinkedList<Integer> list) { int total = 0; for(int i = 0; i < list.size(); i++) total += list.get(i); return total; }
CS 307 – Final – Spring 2010 3 J. What is the worst case Big O of printRev ? Assume the println and length methods are O(1). N = list.size() public void printRev(ArrayList<String> list) { for(int i = list.size() - 1; i >= 0; i--) if(list.get(i).length() < 5) System.out.println(list.get(i)); } K. What is the Big O of method empty if list is a Java LinkedList ?

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.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern