Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
An overview of splay trees, a self-balancing binary search tree. It covers the motivation for using splay trees, their basic operations, and the splaying process. Splay trees are easy to implement and perform well in practice, making them a popular choice for data structures.
Typology: Study notes
1 / 29
Height=4! h
Nodes=31! 2
h+
The same content
Better balanced?
Choose a better root!
Choose a better root!
“Re-wire” the tree
Can we do any better in this case?
Compared to other balanced trees
Each time the tree is accessed (insertion, lookup
or deletion), the deepest node reached is splayed
(it floats) to the root of the tree.
The binary search tree property is maintained
during the splaying.
X! The node being splayed
Y! The parent of X
Z! The grand-parent of X (if it exist)
The two subtrees of X
The sibling of X
The aunt/uncle of X
Based on how X,Y,Z are hooked up together
Y=parent(X)
Z=grand-parent(X)
The node we splay
Objectives:
X moves closer to the root
The partition is maintained
Y=parent(X)
Z=grand-parent(X)
The node we splay
Objectives:
X moves closer to the root
The partition is maintained
The height gets reduced!
We squished the tree!
Y=parent(X)
The node we splay
Objectives:
X moves to the root
The partition is maintained
The height gets reduced!