A self balance BST with the additional property that the recent accessed node are quick to access again.

Splay tree doesn’t require extra space and supports insert, remove, and find operations all in amortized $O(\log{n})$ time and worst case $O(n)$ time.

Operations

Splay

Splaying the tree for a certain node is to rearrange the tree so that that node is put as the root of the tree.

Whenever a node (not root) is accessed, we splay it to move it closer to root. The detailed steps depend on 3 factors:

image.png

other ops

Analysis