67.7k views
5 votes
4. SHORT ANSWERS:

i. Suppose tree T is a min heap of height 3.
- What is the largest number of nodes that T can have? _____________________
- What is the smallest number of nodes that T can have? ____________________

ii. The worst case complexity of deleting any arbitrary node element from heap is ___________

User Lyfe
by
8.8k points

1 Answer

6 votes

Answer:

i. A min heap of height 3 will have a root node with two children, each of which has two children of its own, resulting in a total of 7 nodes at the bottom level. Therefore:

The largest number of nodes that T can have is 1 + 2 + 4 + 7 = 14.

The smallest number of nodes that T can have is 1 + 2 + 4 = 7.

ii. The worst case complexity of deleting any arbitrary node element from a heap is O(log n), where n is the number of nodes in the heap. This is because deleting a node from a heap requires maintaining the heap property, which involves swapping the deleted node with its child nodes in order to ensure that the heap remains complete and that the heap property is satisfied. This process requires traversing the height of the tree, which has a worst-case complexity of O(log n).

Step-by-step explanation:

User SeanCocteau
by
8.9k points