Skip to main content

CIS 263

Tree Exercises

Fall 2019

  1. Draw the binary search tree resulting from the following insertions: 25, 15, 10, 27, 12, 20, 17, 7, 22, 29, 24, 21
  2. For each problem below, begin with this tree (i.e., each answer should be the following tree with only one node missing):
    1. Delete 5
    2. Delete 12
    3. Delete 6
    4. Delete 4
  3. Consider the following binary tree (Note that it is not a search tree because the nodes are in no particular order.)
    1. Write the tree in prefix order
    2. Write the tree in postfix order
    3. Write the tree in infix order
  4. Write a method hasDuplicate that will determine in linear time whether any value appears more than once in a binary search tree. (Assume Nodes with a value, a left pointer, and a right pointer.)
  5. Consider the following AVL tree:
    1. Draw the result of adding 2 to this tree.
    2. Draw the result of removing 17 from this tree. (The original tree.)
  6. When using an AVL tree, when are double rotations necessary?
  7. Consider the following binary max heap:
    1. Draw the result of adding 93 to the heap.
    2. Draw the result of removing the max from his heap (the original).

(Note: Exercises above drawn largely from the Weis text.)


Updated Thursday, 24 October 2019, 3:56 PM

W3c Validation