This preview shows pages 1–2. Sign up to view the full content.
Mehran Sahami
Handout #19
CS103B
February 6, 2009
Practice Midterm Problems
Note: the number of problems here is a larger than you will see on the actual midterm.
More problems are provided here just to give you a bit more practice on a broader set of
the topics that we have covered so far, but the difficulty of the individual problems given
here is likely to be comparable to the mix of the difficulty of individual problems on the
actual midterm (i.e., there are some straightforward questions and some that are more
challenging and involve a bit more thinking).
1.
Consider the
Reverse
Preorder Traversal, where we traverse the right subtree
before
the left subtree, shown in pseudocode below:
Traverse(T)
{
if (T is not empty) {
Process(T(root));
Traverse(T(Right));
Traverse(T(Left));
}
}
Give the order in which nodes are processed if we were to do a reverse preorder
traversal on the following tree:
2.
Give a tight bigOh bound in terms of n for the following function.
Justify how you
obtained your final bigOh bound by explaining how various parts of the function
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.
 Winter '08
 SAHAMI,M

Click to edit the document details