Questions tagged [splay-trees]

26 questions
9
votes
1 answer

Splay tree with odd number of rotations

When inserting an item into a splay tree, rotations are performed in pairs based on either a zig-zag or zig-zig pattern. When there is an odd number of rotations to be performed, one could either do the extra rotation beginning at the leaf or save…
wcochran
  • 265
  • 2
  • 9
8
votes
4 answers

Is there a binary tree structure with fast access to recently accessed elements and worst $O \left( \log n \right )$ complexity?

The idea of splay trees is very nice as they move frequently accessed elements to the top, which can gain a considerable speed up in many applications. The drawback is that in the worst case an operation can have $O(n)$ complexity. (Although…
Petr
  • 2,265
  • 1
  • 17
  • 21
4
votes
1 answer

Make appends not degrade a splay tree

Splay trees offer armotized O(log n) access to tree elements. However, if you keep repeatedly appending elements to a splay tree, without splaying any other elements, it degrades into a linked list with O(n) access. Is there a way to avoid that? I…
4
votes
1 answer

Doubt on Performance Comparison of Splay Trees

I'm trying to understand splay tree performance compared to a standard balanced tree like AVL/red-black. In practice, I am pretty skeptical of the amortized bounds Tarjan and Sleator proves in their paper. Maybe because I am not that smart to…
Silver Flash
  • 205
  • 1
  • 6
2
votes
1 answer

Splay trees: why are depths of nodes on the access path halved?

The original paper describing splay trees Self-Adjusting Binary Search Trees by Sleator and Tarjan claims that: Splaying not only moves x to the root, but roughly halves the depth of every node along the access path. What is the intuition for…
roctothorpe
  • 1,168
  • 8
  • 20
2
votes
0 answers

Efficient Implementation of join and split operations on semisplaying tree

Splaying trees are a heavily researched of theoretical computer science as they are conjectured to be optimal binary trees. They were first presented by Sleator & Tarjan in Self-Adjusting Binary Search Trees. In their paper, on pages 19-20, they…
2
votes
0 answers

Can every node of a link/cut tree be accessed in $O(n)$ time?

Per the Sequential Access Theorem we can access every node of a splay tree in $O(n)$ time, when accessing the nodes in a specific order. Given a link/cut tree, is it possible to access all of its nodes faster than the naive $O(n \log n)$ amortized…
Tyilo
  • 138
  • 9
1
vote
0 answers

Splay Tree - Insert Permutation

Let $T$ be a Splay Tree. For a given permutation $\sigma$ on a set $S = \{1,2,3,...n \}$ we defined the following function: Splay-Insert-Permutation(σ) { FOR i := 1 TO n DO T.Tree-Insert(σ(i)) T.Splay(σ(i)) ENDFOR } We basically insert the…
Maaour
  • 111
  • 1
1
vote
0 answers

Accounting value of Splay trees?

In Splay trees, by definition - the required element x - rises to the root of the tree, using the operations: zig, zig-zig, zig-zag. And the formula zig of the step is this: 1 + 3 (r '(v) -r (v)), where - r' (v) -r (v) is the length of the path…
BadCatss
  • 113
  • 5
1
vote
0 answers

Why is maximum size of root is 2n + 1 in Splay trees?

In the amortized analysis of Splaying in Dynamic trees, let us consider a splay tree $T$ with $n$ keys and $v$ be a node of $T$. We define $size(v)$ as the number of nodes in the subtree rooted at $v$. The size of an internal node is one more…
1
vote
0 answers

Algorithm to recreate a Splay tree

Let's say I have some splay tree as following: I want to recrate the exact same Splay tree using insert(key) method. Is there an algorithm that given some Splay tree traversal (or any other representation) will create the same Splay tree? In other…
vesii
  • 223
  • 1
  • 7
1
vote
1 answer

Splay Tree: Repeatedly searching for the same key that's not in the Tree

In a splay tree, doing $m$ sequential search operations for the same key that is in the tree has a time complexity in $O(n+m)$ where n is the number of nodes in the tree. Since the first search has a worst-case complexity of $O(n)$ and afterwards…
1
vote
0 answers

Splay tree amortized analysis cost using Access Lemma

Currently studying for an algorithms exam and I came across this question and solution, but I can't understand the solution where it references nodes of depth less than $4\log n$ and not restructuring. I understand everything else except for the…
1
vote
1 answer

Prove that a sequence of increasing find operations on a splay tree takes $\mathcal{O}(n)$ time

When studying about splay trees, I found the following statement: Suppose we have a splay tree and a sequence of Find operations, where the elements we are searching for are in increasing order. Then the total time necessary to run the sequence is…
Wanderer
  • 289
  • 1
  • 3
  • 8
1
vote
1 answer

Example of tree with > 6 vertices, tree would have depth = n after splay() deepest vertex

How to build tree with more than 6 vertices, that after operation splay() would have depth = number of vertices? Is it possible? UPD: Example for n = 4: insert 60 insert 10 insert 20 insert 50 splay(10) You can use splay tree visualization
Gleb
  • 57
  • 1
  • 5
1
2