Re: [问题] 有关binomial heap的find min的复杂度

楼主: DJWS (...)   2017-11-30 05:11:19
※ 引述《JinSha ( )》之铭言:
: 所以若是遇到问的问binomial heap的find min的复杂度时,
: 有的地方会说O(log n),有的地方会说O(1)
: 比方说
: https://en.wikipedia.org/wiki/Binomial_heap#cite_note-amortized-9
: http://www.growingwiththeweb.com/data-structures/binomial-heap/overview/
: 这两的地方是说O(log n)
https://en.wikipedia.org/wiki/Binomial_heap#Find_minimum
To find the minimum element of the heap, find the minimum among the roots of
the binomial trees. This can again be done easily in O(log n) time, as there
are just O(log n) trees and hence roots to examine.
By using a pointer to the binomial tree that contains the minimum element,
the time for this operation can be reduced to O(1). The pointer must be
updated when performing any operation other than Find minimum. This can be
done in O(log n) without raising the running time of any operation.
也就是说,原本是 O(log n),但是可以取巧改进到 O(1)。
题外话:
实务上没有人使用 binomial heap,甚至实务上没有人使用任何一种 heap。
同样的事情可以用 binary search tree 做到。(除了合并操作)(感谢LPH66指正)
教科书会写 binomial heap,是因为作者觉得这很有特色,具有一咪咪理论上的价值。
教授上课会教 binomial heap,是因为台湾教授的水平,仅止于复诵教科书。
研究所考试会考 binomial heap,是因为教授要贯彻上意,达成我国愚民教育的方针。
至于正确答案应该要填 O(1) 还是 O(log n),其实是教授说了算,他们爽就好。
反正现实世界没有人在用。
作者: pr3pony   2017-12-01 10:05:00
constant factor 这词算法课本也有提到我有找到 splay tree union 均摊 O(log n) 的论文耶https://goo.gl/vSsAu5
楼主: DJWS (...)   2017-12-01 17:40:00
binomial heap 总共 O(log n) splay tree 总共 O(n log n)虽然均摊 O(log n),但是根本就没有比较意义,所以当我没说
作者: LPH66 (-6.2598534e+18f)   2017-11-30 09:12:00
我不同意 BST 可以取代 heap; 就拿这题的 binomial heap来说, 它提供了 O(log n) 合并两个 heap 的操作这是 BST 无法达成的另外实务上没人用这句话我想打个问号priority queue 这种资料结构就我所知底层都是 heap甚至 C++ STL 有 make_heap push_heap pop_heap sort_heap这都是标准的 binary heap 的操作
作者: hcsoso (索索)   2017-11-30 12:26:00
不过的确就算以学习理论的角度而言, binomial跟Fibonacciheaps为了达成deterministic而使证明复杂的代价太大了.稍微引入一点随机性就可以教treap了, 更别说它跟quicksort的紧密关联...
楼主: DJWS (...)   2017-11-30 18:14:00
@LPH66 合并两个heap,现实世界哪里在使用,请你举个实例有一种 bst 叫做 splay tree,合并操作均摊 O(log n)
作者: pr3pony   2017-11-30 23:22:00
binary heap 常数会比 bst 小吧我觉得这样就算有实用价值了
楼主: DJWS (...)   2017-12-01 04:31:00
楼上可能不知道"常数"是中国竞赛选手自创词汇 工程师讨论这种事情时所用的词汇叫做benchmark另外 除了程式语言内建的binary heap以外 真实世界哪里在使用binary heap 欢迎大家举个实例
作者: oToToT (屁孩)   2017-12-09 00:35:00
binary search tree跟heap写起来难度差那么多...
楼主: DJWS (...)   2017-12-09 07:33:00
compiler = 100 bst = 2 heap = 1 似乎是比较难没错啦
作者: Arton0306 (Ar藤)   2016-01-02 23:35:00
我做的是eda中physical design里面的p&r tool我们的code就有heap 而且是自己写的
楼主: DJWS (...)   2016-01-12 15:04:00
那请教你,输入资料数量多大?还有就是,是什么任务需要即时得知最小值?

Links booklink

Contact Us: admin [ a t ] ucptt.com