A splay tree is a self-adjusting binary search tree with excellent amortized performance.
Questions tagged [splay-tree]
70 questions
3
votes
2 answers
When I traverse in the splay tree, then now which one is root?
I had a doubt when we are using a splay tree, the last accessed element will come to the root node. consider my tree is
5
/ \
3 7
/ \ / \
2 4 6 …

Bhuvanesh
- 1,269
- 1
- 15
- 25
3
votes
2 answers
Recursive Splay Tree
I am trying to implement a recursive splay tree, bottom up. I recurse down to the node I am need to splay up, and I find the parent and grandparent of that node. Then I am able to either zig zag or zig zig depending on the situation just fine. The…

Andrew
- 31
- 2
3
votes
0 answers
Determining if a binary search tree can be constructed by a sequence of splay tree insertions
A splay tree is a type of self-adjusting binary search tree. Inserting a node into a splay tree involves inserting it as a leaf in the binary search tree, then bringing that node up to the root via a "splay" operation.
Let us say a binary search…

augurar
- 12,081
- 6
- 50
- 65
3
votes
1 answer
What's the best way to compare the efficiency of splay trees?
I have implemented several splay tree algorithms.
What's the best way to compare them?
Is it a good start to compare execution time when adding random nodes?
I've also implemented an Binary Search Tree that keeps track of how much every node is…

Jan Konicks
- 31
- 2
2
votes
1 answer
Why is amortized analysis of splay tree only focusing on the splay operation and not accounting for the downwards search
Each dictionary operation in a splay tree uses a splay operation to bring a node to the root of the tree. The amortized efficiency of this splay operation is typically analyzed with the potential method and described in many sources online…

user3820186
- 143
- 1
- 1
- 6
2
votes
1 answer
Update key attribute in map
I have got a recursive SplayTreeMap (autogenerated) like this (pseudocode):
SplayTreeMap map = {
Entry('path', 'cooltype'): {
Entry('subpath', 'othercooltype'): {
Entry('subsubpath',…

aleskva
- 1,644
- 2
- 21
- 40
2
votes
1 answer
What is faster in practice: Treap or Splay tree?
I've learned both Treap and Splay tree and solved few problems using them.
In theory, their complexity is O(log n) on average, but in worst-case Treap's complexity is O(n) while Splay tree's is amortized O(log n).
In which case does worst case…

NikolaTECH
- 76
- 10
2
votes
1 answer
How can I use splay tree data structure in huffman coding for data compression?
First of all, I am new to programming, so I would expect simple and well explained answers. Secondly this is a very specific question and I don't want moderators and other users to just close this question as off-topic or for being too broad.…
user5987642
2
votes
1 answer
Splay Tree Zig-Zag & Zag-Zig Rotation ISSUE
OK, so here is splay algorithm, if you want to check.
Here is my splay function:
template
void SplayTree::Do_Splay(SplayNODE *temp) //temp is the node which is to be splayed
{
if (temp==root) //if temp is root then
{ …

InamTaj
- 276
- 2
- 7
- 15
2
votes
1 answer
How can I rotate Nodes in a splay tree?
The code I have is
private Node rotateLeftChild(Node n)
{
Node o = n.left;
n.left = o.right;
o.right = n;
return o;
}
When I call it to rotate a tree like this at the root:
7
/ \
4 8
/…

Pat Gallagher
- 83
- 2
- 10
2
votes
1 answer
Splay tree rotation algorithm: Why use zig-zig and zig-zag instead of simpler rotations?
I don't quite understand why the rotation in the splay tree data structure is taking into account not only the parent of the rating node, but also the grandparent (zig-zag and zig-zig operation). Why would the following not work:
as we insert, for…

Bober02
- 15,034
- 31
- 92
- 178
1
vote
0 answers
Bottom up Splay trees vs Top down splay trees
I'm trying to learn more about Splay trees but there is very little information to be found online about the difference between Top-down splay trees and Bottom up splay trees. Can anyone tell me what's the difference between Top-down and bottom up…

RazerMackham
- 55
- 4
1
vote
1 answer
Is there a better way to do a self-reference pointer in the base class that also works in derived classes?
I am writing some code on Splay Tree nodes. Without being too technical, I want to implement one base tree and one derived tree that supports reversion of the left and right sub-trees. The current excerpt looks like this:
struct node {
node *f,…

zhtluo
- 33
- 4
1
vote
1 answer
Why is splay tree in textbook different than mine?
In Data Structures and Algorithm Analysis in C++ (4th Edition) by Mark Allen Weiss, on page 162 at figure 4.50, the book describes how splaying the left most child of tree with only left children would ultimately look like.
Where I am confused is…

Darien Springer
- 467
- 8
- 17
1
vote
1 answer
Find the cause of 'SEGV on unknown address', cause by READ access
I'm writing a Splay Tree implementation. Code compiles just fine in VS, but the testing system fails with DEADLYSIGNAL.
The specific input for testing is:
search 66
min
max
set 1 20
print
Here is the full code:
#include
#include…

asymmetriq
- 195
- 1
- 8