3. What is Splay Tree?
Splay trees are self-adjusting binary search
trees.
A node in a Binary_Search_Tree is
"splayed" when it is moved to the root of the
tree by one or more "rotations".
Whenever a node is accessed (Find, Insert,
Remove, etc.), it is splayed, thereby making it
the root.
In addition to moving the accessed node to
the root, the height of the tree may be
shortened.
4. Splay tree Rules
Zig: Rotate the node about its parent
(left or right).
Zig_Zig: Rotate the parent about the
grandparent (left or right), then rotate
the node about its parent in the same
direction.
Zig_Zag: Rotate the node about its
parent (left or right), then rotate the
node about its grandparent in the other
direction.
42. SPLAY TREE TIME COMPLEXITY
Sorted List Search Insertion Deletion
with arrays O(log n) O(n) O(n)
with linked list O(n) O(n) O(n)
With Splay
trees
O(log n) O(log n) O(log n)
43. Splay Tree Usage
Memory allocators
Routers
Garbage collectors
Data compression
44. Advantage :
Simple Implementation
Comparable performance
Small memory footprint
Working well with nodes containing
identical keys
Disadvantage:
Height can be linear
Extra management is needed if
multiple threads are allowed to perform
FIND operations.
Splay tree can be worse than Static
tree.