Fall2021 Test2
Fall2021 Test2
PART I: DEFINITIONS
Define the following words or phrases related to trees: binary tree, Strictly Binary tree, Full Binary
Tree, Complete Binary Tree, Binary Search Tree, AVL Tree, 2-4 Tree, B-Tree, Red-Black Tree,
balance factor, left-heavy, and right-heavy, 2-node, 3-node, and 4-node, external node, black depth.
Exercise 2. AVL
1. Given the following AVL Tree:
a. Draw the resulting AVL after 5 is removed, but before any rebalancing takes place. Label
each node in the resulting tree with its balance factor.
b. Now rebalance the tree that results from (i). Draw a new tree for each rotation that occurs
when rebalancing the AVL Tree (you only need to draw one tree that results from an RL
or LR rotation). You do not need to label these trees with balance factors.
2. Show the change of an AVL tree when inserting 1, 2, 3, 4, 10, 9, 7, 5, into the tree, in this
order.
3. For the tree built in the preceding question, show its change after 1, 2, 3, 4, 10, 9, 7, 5, are
deleted from the tree in this order.
Exercise 3: 2-4 trees and B-Trees
1. Explain how to search an element from a 2-4 tree.
2. Show the change of a 2–4 tree when inserting 1, 2, 3, 13, 4, 0,11, 10, 9, 7, 5, 8, and 6 into
it, in this order.
3. Show the process to sequentially delete 90, 52, 17, 32, and 68 from the following 2-4 tree
4. Construct a B-Tree of order 5 for the following data: 1, 6, 7, 2, 11, 5, 10, 13, 12, 20, 16, 24,
3, 4, 18, 19, 14, 25
Exercise 4: Red black trees
1. What are the three properties that characterize a red black tree?
2. How do you convert a 2-4 tree to a red black tree? Illustrate with an example.
3. How do you convert a red black tree to a 2-4 tree? Illustrate with an example.
4. Show the change of the tree when inserting 1, 2, 3, 4, 10, 9, 7, 5, 8, and 6 into it, in this
order.
5. For the tree built in the preceding question, show the change of the tree after deleting 1, 2,
3, 4, 10, 9, 7, 5, 8, and 6 from it in this order.