Lecture 18: Red Black Trees

10/7/2020

The Bad News

BST Structure and Tree Rotation

BSTs

Tree Rotation Definition

Rotation for Balance

Rotation: An Alternate Approach to Balance

Red-Black Trees

Search Trees

Representing a 2-3 Tree as a BST

Left-Leaning Red Black Binary Search Tree (LLRB)

Red Black Tree Properties

Left-Leaning Red Black Binary Search Tree (LLRB)

Left-Leaning Red Black Binary Search Tree (LLRB) Properties

LLRB Construction

Maintaining 1-1 Correspondence Through Rotations

The 1-1 Mapping

Design Task 1: Insertion Color

Design Task 2: Insertion on the Right

New Rule: Representation of Temporary 4-Nodes

Design Task 3: Double insertion on the left

Design Task 4: Splitting Temporary 4-nodes

That's it!

LLRB Runtime and Implementation

LLRB Runtime

LLRB Implementation

Search Tree Summary

Search Tree

CSM Review

B-Trees

2-3 Trees

2-3-4 Trees

Traversals

Rotating Nodes

Left-Leaning Red Black Trees

Tree Traversals