Data Structures & Algorithms Lecture Notes

24 November 2010 • Balancing Trees


Outline

  • Tree Shape
  • Rebalancing Trees
    • AVL Trees
    • Red-Black Trees
  • Caching
    • Splay Trees
a balanced tree

Tree Shape

Representing Balance

Getting Balanced Trees

Tree Balance

Node Rotations

Example Node Rotations

Tree Rebalancing

Example Rebalancing

an example rebalancing

AVL Trees

AVL Rotations

AVL Balance

Almost-Balanced Trees

Red-Black Trees

The Red-Black Property

Example Red-Black Tree

Maintaining Almost Balance

Abandoning Balance

Unbalanced Trees

Caching

A List Cache

List Caching Example

Caching Tree Accesses

Splay Trees

Splaying

Splay Insertion

Splay Deletion

Splay-Deletion Example

Summary

References

Credits


This page last modified on 14 October 2008.

Creative
    Commons License