You are on page 1of 2

COL106: Quiz-3 Name:

Maximum marks: 10 Entry number: 2 0

Question 1 Let T be a 2-3-4 Tree of height h (that is, leaves are at a distance h from root)
satisfying that deletion of any element from the tree decreases its height by one. Obtain a tight
upper bound on the total number of elements that can lie in this 2-3-4 tree. Explain. [5 marks]

Claim: Each node in the tree is a 2-node.

Proof: Assume on contrary there is a node in T that is not a 2-node.


Let x be a node in T of maximum depth (or level) that is not a 2-node. So, all descendants
of x are 2-node. Let y be a leaf that is descendant of x (if x itself is leaf then y is simply x).
Now on deletion of unique entry in y, there will be an under flow in y. However, this un-
derflow will propagate only till node x as x is not a 2-node. This violates the condition that
‘deletion of any element from the tree decreases its height by one’, thereby proving that each
node in T is a 2-node.

Therefore, the number of nodes in T is simply 1 + 2 + 4 + . . . + 2h = 2h+1 − 1.


Question 2 Consider a max heap represented by the array A = [40, 30, 20, 10, 15, 16, 17, 8].
Perform the following operations in the given order, and draw the tree after each operation.
Clearly show the intermediate steps involved. [5 marks]

1. Insert 35

2. Delete 40

You might also like