Problem Set: Trees
-
What are the preorder, inorder, and postorder traversals of the tree
shown above?
- Is the tree shown above a BST? If not, why not?
- Is the tree above balanced? If not, where is it out of balance?
- What is the level of the following nodes: G, W, and U?
- What is the height of the tree?
- Is the BST above balanced? If not, where is it out of balance?
- What is the height of the subtree rooted at G?
- What is the level of O? What is the level of J?
- Starting with the BST given above, show the tree after
calling the delete method to delete each of the following items,
in the order G, O, L.
-
What are the preorder, inorder, and postorder traversals of the tree
shown above?
- Is the tree shown above a BST? If not, why not?
- Starting with the BST given above, show the tree after
calling the delete method to delete the following items,
in the given order: 55, 95, 20, 75, 77, 100.
- Beginning with an empty BST, show the search tree that
is formed when you insert the following values in the order
given.
- W T N J E B A
- W T N A B E J
- B N A W J T E
- J N B A W E T
- Beginning with an empty BST, show the search tree that
is formed when you insert the following values in the order
given.
- 40 80 70 10 30 90 60 20 50
- 50 60 20 90 10 80 40 30 70
- 80 20 60 70 30 10 40 50 90
- Suppose a BST stores integers in the range 1 to 1000. Which of
the following search sequences is not possible when searching
for the value 410 in this tree?
- 620, 255, 350, 520, 480, 410
- 590, 400, 500, 300, 350, 410
- 100, 350, 600, 400, 500, 450
- 150, 200, 320, 300, 350, 400
- Suppose a BST stores integers in the range 1 to 1000. Which of
the following search sequences is not possible when searching
for the value 225 in this tree?
- 500, 355, 150, 320, 200, 225
- 500, 400, 200, 300, 200, 350, 225
- 50, 100, 600, 400, 40, 120
- 50, 500, 100, 400, 200, 300
- Write a method for the BST class (using recursion) to count the number of nodes
in a BST.
- Write a method for the BST class (using recursion) to compute the height of a BST.
- Write a method for the BST class (using recursion) to find the maximum element
in a BST.
- Write a method for the BST class (using recursion) that visits the nodes in reverse
sorted order.
- Write a function (client code) to print out all the objects in a BST
of Pet objects. Print the objects in sorted order. The parameter is the
tree.
Email Me |
Office Hours |
My Home Page |
Department Home |
MCC Home Page
© Copyright Emmi Schatz 2016