Question: Suppose that binary heaps are represented using explicit links. Consider the problem of merging binary heap lhs with rhs. Assume both heaps are perfect binary

Suppose that binary heaps are represented using explicit links. Consider the problem of merging binary heap lhs with rhs. Assume both heaps are perfect binary trees, containing 2l − 1 and 2r − 1 nodes, respectively.
a. Give an O(logN) algorithm to merge the two heaps if l = r.
b. Give an O(logN) algorithm to merge the two heaps if |l − r| = 1.
c. Give an O(log2 N) algorithm to merge the two heaps regardless of l and r.

Step by Step Solution

3.48 Rating (187 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

a Place negative infinity as a root with the two heaps as ... View full answer

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

Document Format (1 attachment)

Word file Icon

1486-C-S-A(384).docx

120 KBs Word File

Students Have Also Explored These Related Algorithms Questions!