Binary Search Trees

2/18/02


Click here to start


Table of Contents

Binary Search Trees

(recall:) The Dictionary ADT

Binary Search Trees: Motivation

Binary Search Trees: Definition

BST Example

Performance

AVL Trees

Example AVL Tree

Negative Example AVL Tree

Example AVL Search Tree

AVL Tree: Lookup cost

AVL (Search) Tree (Easy) Insertion Example

AVL (Search) Tree (Harder) Insertion Example

AVL Tree Single Rotation Left

Now insert EGG

Prepare for Left rotation

Left Rotation Done

Prepare for Right Rotation

Right Rotation Done; Balance Restored

Use of Balance Factors

Insert FUN

Prepare to Rotate left at C

Rebalanced

General AVL Insertion Method

Single rotations classified according to which grandchild is too heavy

Double rotations classified according to which grandchild is too heavy

LL Rotation: Schematic

LR Rotation: Schematic

Deletion from an AVL Tree

Author: Steven L. Tanimoto

Email: tanimoto@cs.washington.edu

Home Page: www.cs.washington.edu/people/faculty/tanimoto.html

Download presentation source