Fa06Final

# Fa06Final - Points off 1 2 3 4 5 6 Total off Net Score CS...

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
For parts B - E consider the following binary tree. For each question assume when a node is processed the value in the node is printed out by the statement: System.out.print( currentNode.getData() + " " ); B. What is the output of a preorder traversal of the above tree? C. What is the output of an inorder traversal of the above tree? D. What is the output of a postorder traversal of the above tree? E. Is the binary tree shown above a binary search tree? Assume characters are compared based on alphabetical order. CS 307 – Final – Fall 2006 2 root of tree 'S' 'I' 'R' 'T' 'E' 'K' 'N'
What is the output of the following code segment? Queue<Integer> q = new Queue<Integer>(); Stack<Integer> s = new Stack<Integer>(); for(int i = 1; i < 20; i += 3){ if( i % 2 == 0 ) q.enqueue(i); else s.push( i ); } System.out.print( s.pop() + " " ); System.out.print( q.dequeue() + " " ); } For questions G. and H. consider the following Queue class public class Queue<AnyType>{ private ArrayList<AnyType> myCon; public Queue(){ myCon = new ArrayList<AnyType>(); } public AnyType front(){ return myCon.get( myCon.size() - 1 ); } public AnyType dequeue(){ return myCon.remove( myCon.size() - 1 ); } public boolean isEmpty(){ return myCon.size() == 0;

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 ]}

### Page1 / 22

Fa06Final - Points off 1 2 3 4 5 6 Total off Net Score CS...

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

View Full Document
Ask a homework question - tutors are online