Exercises - Lecture 9

9A

  1. Which of the following are binary search trees?

  2. Write the values printed by an in-order traversal of each of the following BSTs. What do you notice about the resulting sequences?

  3. Draw the binary tree resulting from the following sequence of insertions:

  4. Draw the binary tree resulting from the following sequence of insertions:

  5. Implement the minimum method in the following BST class, which finds the smallest value in a BST:

9B

  1. T / F Searching a binary search tree has a better worst-case runtime than searching a linked list.
  2. T / F Searching a binary search tree has a better best-case runtime than searching a linked list if the element is not in the list/tree.

9C

  1. Perform the following operations in sequence on the tree given below. Draw the resulting tree after each operation.

remove(9)
remove(4)
remove(10)