简体   繁体   中英

Merging two perfect binary heaps?

I've been stuck on a question for a while and was wondering if anyone can point me in the right direction:

Suppose binary heaps are represented using a pointer-based tree representation instead of an array. Consider the problem of merging binary heap LHS with RHS. Assume both heaps are full complete trees, containing (2^L - 1) and (2^R -1) nodes, respectively.
Give two O(log N) algorithms to merge the two heaps, one if L = R and one if |L - R| = 1.

This is a homework problem, I just need to be pointed in the right direction.

Hint for L=R: pretend you've just removed the root. Let me know if you need more.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM