Suppose a Min-Heap stores keys. The height of is ___________. (Answer in integer)
View worked solution
Answer: 5:5
A Min-Heap is represented as a complete binary tree.
The height of a rooted tree is defined as the maximum number of edges from the root to any leaf node. For a complete binary tree with nodes, the height is given by the formula:
Given that the Min-Heap stores keys:
Alternative Level-by-Level Verification:
We can determine the level of each node starting from the root at Level 0:
- Level 0: node (Cumulative total: )
- Level 1: nodes (Cumulative total: )
- Level 2: nodes (Cumulative total: )
- Level 3: nodes (Cumulative total: )
- Level 4: nodes (Cumulative total: )
- Level 5: node (Cumulative total: )
Since the node resides at Level 5, the maximum path length from the root to this leaf node is edges.
Thus, the height of the Min-Heap is 5.
Free practice · Your answers on this page are not saved.
