Questions tagged [splay-tree]

A splay tree is a self-adjusting binary search tree with excellent amortized performance.

70 questions
0
votes
1 answer

Testing Splay Trees

I am trying to find an applet online to test splay trees, but none of them that I have found so far satisfy what I need. I need something where I can input the already constructed splay tree. I have the initial tree, but cannot construct it using…
Flipper
  • 2,589
  • 3
  • 24
  • 32
0
votes
1 answer

Using a generic Pair class and a Splaytree to count and store words and their frequencies in Java

I'm implementing a splaytree to hold words and their frequencies and chose to create a Pair class that would hold each word-frequency (key-value) pair. That is, each node of the splaytree holds a pair of the Pair class. The Pair class looks like…
Snorkelfarsan
  • 485
  • 1
  • 6
  • 11
0
votes
1 answer

Null pointer exception in bottom up splay tree splaying

I am trying to do a bottom up splay tree in java. But somehow, I would get a null-pointer exception in my rotation method when I build a tree, add several elements, and try to splay the inserted node to the top. Can anyone tell me why I get that…
spider
  • 53
  • 5
0
votes
0 answers

Splay Tree insertion time efficiency with different input cases

So I used the same splaytree used in geeksforgeeks and did some experiment with it: code: https://www.geeksforgeeks.org/insertion-in-splay-tree/?ref=rp vers.1 #include // the code for splaytree is too long so I just put the link…
0
votes
0 answers

Get the index upon insertion in SplayTreeSet in dart

I have a SplayTreeSet in dart and I was wondering wether I could get the position where the object is inserted. Usually I would know it as length - 1, but since in SplayTreeSet are sorted, I am not sure the item will end up at the end. Is there a…
Fabrizio
  • 1,138
  • 4
  • 18
  • 41
0
votes
0 answers

How do implement a remove function in a splay tree?

Ive built my entire splay tree program successfully, every function works- splay, rotate, find and insert, but im trying to implement remove. My strategy so far has been to find and splay the element im trying to remove, deleting the node and…
Dman
  • 1
  • 3
0
votes
0 answers

How to get the Key and Value pair from Splay tree using Java

public static void main(String[] args) { SplayTree st1 = new SplayTree(); st1.put(5, 8645365); st1.put(9, 9); st1.put(13, 13); st1.put(11, 11); st1.put(1, 1); …
0
votes
2 answers

Regarding splay trees

I am reading about splay trees in Data structures and algorithms by Mark Allen Wesis The splaying strategy is similar to the rotation idea, except that we are a little more selective about how rotations are performed. We will still rotate…
venkysmarty
  • 11,099
  • 25
  • 101
  • 184
0
votes
1 answer

Looping over a SplayTreeMap doesn't give values with duplicated keys

I have a SplayTreeMap of players with their levels, and I wanna print a ranking of these players based on their level. When I use .forEach to iterate over this SplayTreeMap, it ignores the players with the same level (means that while looping over…
arrmani88
  • 756
  • 8
  • 25
0
votes
1 answer

How can I design this function to work in logarithmic time?

I have a splay tree for which I have implemented range_sum(left,right) which adds all the elements in the tree in range from left to right and it works in logarithmic time, is there anyway I can make a function range_up(left,right ,delta) which adds…
aelc
  • 13
  • 5
0
votes
1 answer

How to delete min element in splay tree

I made a splay tree, but I don't understand how to delete min element from it, can someone help please? data Splay a = Empty | Node a (Splay a) (Splay a) deriving Show data Direction = L | R deriving Eq rotate :: Direction -> Splay a -> Splay…
0
votes
1 answer

Implementing a splay tree

I am trying to implement splay tree. The code goes into infinite loop printing 20 10 20 15 10 20 15 15 10 10 20 15 for below test code and it goes on repeating itself. I have tried debugging but i cannot find where it is going wrong. The code runs…
user14186428
0
votes
2 answers

Splay Tree Implementation

I am trying to implement a splay tree. But there is a segmentation fault occuring in the left_rotate and right_rotate function which is being called by splay() function. I have tried debugging but left with no clue. where am i doing wrong! I think…
user13963926
0
votes
1 answer

Auto adjusting rotations strategy in splay trees

I have to implement the splay tree structure using java. Given a class called Node that has : the left, right child info (an int) the height of a node my homework consist to create the "insert" method. I've tried some strategies but it hasnt work…
0
votes
1 answer

What is the complexity of insertion operation for 1...n keys in BST and Splay tree?

If n keys 1,2,…,n are to be inserted in that order, (a). to a normal BST (Binary Search Tree) (b). to a Splay Tree What would be the complexity in each case (a), b) ? Is it O(log n) for both the cases? Or is it O(log n) for (a) and O(M log n) for…