[英]How to implement an algorithm to merge two heaps with n=2^k number of elements in O (k) time?
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. 这只需要O(n)的最小时间来合并两个排序的数组,我不知道如何在O(k)时间内合并。
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.
此问题的目的是探索以自上而下的方式有效构建标准堆的可能性。
Give a high level description of an algorithm that merges two standard heaps which each contain exactly n = 2^k elements.
给出一个算法的高级描述,该算法合并两个标准堆,每个堆包含n = 2 ^ k个元素。 The algorithm should run in O(k)time.
该算法应在O(k)时间内运行。
Using the subroutine as specified in part 1, give a recursive or iterative algorithm that builds a heap of 2^n elements.
使用第1部分中指定的子例程,给出一个递归或迭代算法,构建一个2 ^ n个元素的堆。
Write down an equation for the running time of the algorithm specified in part 2, solve it.
记下第2部分中指定的算法运行时间的等式,求解它。
You can use the Binomial_heap or Leftist heaps . 您可以使用Binomial_heap或Leftist堆 。
When n=2^k they all have merge operation in O(k) time. 当n = 2 ^ k时,它们都在O(k)时间内具有合并操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.