232ICS202Assignment3 202157210
232ICS202Assignment3 202157210
Question I. (25 points) (Binary Heaps) Consider a perfect binary tree of height ℎ ≥ 0.
a. (5 points) How many nodes does the tree have (in terms of ℎ).
b. (20 points) Show that applying the bottom-up algorithm for building a heap on a perfect binary tree
costs Θ(𝑛) element comparisons, where 𝑛 is the number of nodes in the perfect binary tree.
Page 1 of 5
Question II. (25 points) (Binary Heaps)
Sort the following array using heap sort algorithm. [77, 45, 38, 28, 12, 17, 9]
Page 2 of 5
Question III. (30 points) (B-Trees)
Insert 12, 29, 23, 39, 43, 26, 48, 27, 20, 60, 57, 50 in a B tree of order M=3
Page 3 of 5
Question IV. (20 points) (B Trees)
a. (10 points) Delete the key 91 in the following B-tree of order 5
Page 4 of 5
b. (10 points) Delete the key 40 in the following B-tree of order 3
Page 5 of 5