简体   繁体   English

Splay树最坏案例搜索时间

[英]Splay Tree Worst Case Search Time

Since splay tree is a type of unbalanced binary search tree ( brilliant.org/wiki/splay-tree ), it cannot guarantee a height of at most O(log(n)). 由于splay树是一种不平衡的二叉搜索树brilliant.org/wiki/splay-tree ),因此它不能保证高度不超过O(log(n))。 Thus, I would think it cannot guarantee a worst case search time of O(log(n)). 因此,我认为它不能保证最坏情况下的O(log(n))搜索时间。

But according to bigocheatsheet.com : 但是根据bigocheatsheet.com

在此处输入图片说明

Splay Tree has worst case search time of O(log(n))??? Splay树的最坏情况下搜索时间为O(log(n))???

You're correct; 没错 the cost of a lookup in a splay tree can reach Θ(n) for an imbalanced tree. 对于不平衡树,在展开树中查找的成本可以达到Θ(n)。

Many resources like the big-O cheat sheet either make simplifying assumptions or just have factually incorrect data in them. 诸如big-O备忘单之类的许多资源要么简化了假设,要么仅包含事实不正确的数据。 It's unclear whether they were just wrong here, or whether they were talking amortized worst case, etc. 目前尚不清楚他们是不是在这里错了,或者他们是在摊销最坏的情况,等等。

It's always best to know the internals of the data structures you're working with so that you can understand where the runtimes come from. 始终最好了解正在使用的数据结构的内部,以便您可以了解运行时的来源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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