How to implement an algorithm to merge two heaps with n=2^k number of elements in O (k) time?

240 Views Asked by At

However, I don't even know what this problem means.

This only takes a minimum time of O (n) to just merge the two sorted arrays, I don't know how to merge in O (k) time.

This is a total of three problems associated with it:

The purpose of this problem is to explore the possibility of building a standard heap efficiently in a top-down manner.

  1. Give a high level description of an algorithm that merges two standard heaps which each contain exactly n = 2^k elements. The algorithm should run in O(k)time.

  2. Using the subroutine as specified in part 1, give a recursive or iterative algorithm that builds a heap of 2^n elements.

  3. Write down an equation for the running time of the algorithm specified in part 2, solve it.

1

There are 1 best solutions below

0
Levey On

You can use the Binomial_heap or Leftist heaps.

When n=2^k they all have merge operation in O(k) time.