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 H1, H2 of size 5 and the same root, each containing two
items A1, A2 with the same key. Suppose the remove operation is performed
simultaneously for the two heaps. H1 should have A1 removed before H2
removes A2, despite A1 and A2 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 3 nodes, Root, LeftChild, RightChild
has 2 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!