简体   繁体   English

八卦树的摊销复杂度是多少?

[英]what is amortized complexity in splay tree?

I tried to understand the amortized complexity and did several searches on the net, but I couldn't find a good resource yet. 我试图了解摊销后的复杂性,并在网上进行了几次搜索,但是我找不到很好的资源。

So can any one explain what amortized complexity is and how it becomes O(lg n) in splay tree per operation? 那么,有谁能解释摊销复杂度是什么,以及每项操作在摊分树中如何变成O(lg n)?

Any operation performed on splay trees whether insert delete..etc the cost is dominated by the splay operation. 在splay树上执行的任何操作(无论是否插入delete..etc)都由splay操作决定。 hence accounting for the cost of only the splay operation which is the rotations performed on the node to be splayed. 因此,仅考虑张开操作的成本,即张开操作是在要张开的节点上执行的旋转。

The amortized function is given by a=c+3Rfinal(v)-3Rinitial(v)

where a is the amortized cost, c is the actual cost and Rfinal is the rank after the splay operation and Rinitial is the rank of the node before rotation.(rank of any node is given by the height of its subtree ie log|S| where S is the number of nodes rooted under it) 其中,a是摊销成本,c是实际成本,Rfinal是展开操作之后的等级,Rinitial是旋转之前节点的等级。(任何节点的等级均由其子树的高度给出,即log | S |其中S是根植于其下的节点数)

Now consider the worst case where node to be splayed, is the leaf hence its initial rank is given by 0. After splaying it to the top ie as the root node its rank becomes log n where n is the total number of nodes in the tree. 现在考虑最糟糕的情况,其中要张开的节点是叶子,因此其初始等级为0。张开到顶部之后,即,作为根节点,其等级变为log n,其中n是树中节点的总数。

 a<= 2+3logn-0
 O(logn).

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

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