Question: ( a ) Draw two min heaps H 1 , H 2 of size 5 and the same root, each containing two items A 1
a Draw two min heaps H H of size and the same root, each containing two
items A A with the same key. Suppose the remove operation is performed
simultaneously for the two heaps. H should have A removed before H
removes A despite A and A having the same key.
b Give an algorithm for retrieving all of the paths from the root to any leaf node
in a heap. For example, a heap with nodes, Root, LeftChild, RightChild
has paths to leaf nodes:
Root LeftChild and Root RightChild.
Do not assume an array implementation for the heap. You may assume at
any node that there is access to the left child, right child, and parent.
c Determine the total number of paths that would be returned in part b for a
heap with height h that are perfect binary trees.
d Prove part c by induction.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
