Intuition behind a tree tree (own balancing trees)

I am reading the basics of splay trees. Amortized cost of transaction - O (log n) over n operations. Some rough basic idea is that when you access the node, you translate it, that is, you take it for root, so next time it will be quick access, and also, if the node is deep, it will improve tree balancing.

I do not understand how a tree can do O (log n) depreciation for this input:

Let's say that a tree of n nodes has already been built. My next n operations are n reads. I am referring to a deep node at depth n. It takes O (n). True, after this access the tree will become balanced. But tell me every time I access the deepest node. It will never be less than O (log n). then how can we ever compensate for the first expensive operation O (n) and bring the amortized cost of each of them as O (log n)?

Thank.

+5
source share
1 answer

Assuming your analysis is correct, and O(log(n))access operations for the O(n)first time ...

( - ), a O(a*log(n) + n). , , O((a*log(n) + n)/a)= O(log(n) + n/a) O(log(n)) , .

//, " //". , O(n) , O(n); ; O(...) , , [total amount of work]/[queries]= [average ("amortized") work per query].

, O (log n).

, O(log n). , - : http://users.informatik.uni-halle.de/~jopsi/dinf504/chap4.shtml, http://users.informatik.uni-halle.de/~jopsi/dinf504/splay_example.gif - , , O(n), , , . , O(n), .

:

. O(n) . , *, O(log(n)) . , , , , () , . (* , , splay)

+6

All Articles