Splay trees

Published

2023-08-05

Splay trees are another kind of self-balancing tree developed by Sleator and Tarjan in 1985. These trees have a caching feature, in addition to self-balancing. Splay trees do not provide as strong a constraint on balance as AVL trees do, but they perform as well and sometimes better in similar applications.

Now use the USF algorithm visualization tool. Slow down the animation speed so you can observe carefully what’s going on. Try a sequence of insertions, searches, and deletions. Experiment: try to make the most unbalanced tree you can. How do you go about that? Try to make the most balanced tree you can. How do you go about that?

Splay tree visualization

What was the most unbalanced tree you could produce? What was the most balanced tree you could produce?

Resources

Comprehension check:

  1. True or false? A splay tree guarantees that single access occurs in \mathcal{O}(\log n) time.
  2. When deleting a node, a splay tree first splays the node to the __________ and then deletes it.
  3. When encountering a zig-zig case at node x, splay tree rotates the edge joining the parent and ____________ of x, and then rotates the edge joining x and its ______________.
  4. True or false? Once a value is at the root, it can be accessed again in \mathcal{O}(1) or constant time.
  5. A splay tree is designed to take advantage of _______________ of reference.

Answers: ʎʇᴉlɐɔol / ǝnɹʇ / ʇuǝɹɐd / ʇuǝɹɐdpuɐɹƃ / ʇooɹ / ǝslɐɟ

Original author: Clayton Cafiero < [given name] DOT [surname] AT uvm DOT edu >

No generative AI was used in producing this material. This was written the old-fashioned way.

All materials copyright © 2020–2023, The University of Vermont. All rights reserved.