CPS 100E, Fall 1996 Inlab 9
Name:
Lab Section:
You should answer the following questions and either
turn in the sheet during lab, or answer the questions
when you submit your README file.
These questions are worth 2 out
of the 10 points for each lab. You don't need to get all
the answers right to get the 2 points, but you must try.
It's ok to ask a UTA or TA for help, but first you must
try to find the answers on your own.
- What is the maximum number of nodes that a binary tree
with height 3 have? What is the maximum number of nodes that
a binary tree with a height of 4 have? How about n nodes?
- In what order would the function DisplayStack light up the
nodes in the tree created when you read in test.dat if we made
the following change to the function DoInorer?
static void DoInorder(TreeNode * root, Stack & stack)
// postcondition: tree is Inordered in a preorder traversal
{
if (root != 0)
{
// Push subtrees in order
stack.Push(root);
DoInorder(root->right, stack);
DoInorder(root->left, stack);
}
}
- What is the maximum diameter of a tree that has a height of
3? How about 4? How about n?
- If we do the following operations on the binary tree:
- Read the file test.dat
- Add mouse to the tree
- Add moose to the tree
- Delete monkey from the tree
What word would be at the root of the tree?
- Explain how the function DeleteTree works?