Computer Algorithms II Lecture Notes

27 November 2007 • Balancing Trees


Outline

  • Tree Shape

  • Rebalancing Trees

    • AVL Trees

    • Red-Black Trees

  • Caching

    • Splay Trees

a balanced tree

A Question

Data Insertion Order

Tree Levels

Tree Shape

Examples

Representing Balance

Getting Balanced Trees

Tree Balance

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

Caching Tree Accesses

Splay Trees

Splaying

Summary

Credits


This page last modified on 26 November 2007.

This work's CC license.