GNU libavl 2.0.1
Author: Ben Pfaff

9 Threaded Red-Black Trees |

In the last two chapters, we introduced the idea of a threaded binary search tree, then applied that idea to AVL trees to produce threaded AVL trees. In this chapter, we will apply the idea of threading to red-black trees, resulting in threaded red-black or "TRB" trees.

Here's an outline of the table implementation for threaded RB trees, which use a trb_ prefix.

    333. <trb.h 333> =
    <License 1>
    #ifndef TRB_H
    #define TRB_H 1

    #include <stddef.h>

    <Table types; tbl => trb 14>
    <RB maximum height; rb => trb 195>
    <TBST table structure; tbst => trb 250>
    <TRB node structure 335>
    <TBST traverser structure; tbst => trb 267>
    <Table function prototypes; tbl => trb 15>

    #endif /* trb.h */

    334. <trb.c 334> =
    <License 1>
    #include <assert.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include "trb.h"

    <TRB functions 336>

Sections:

- 9.1 Data Types
- 9.2 Operations
- 9.3 Insertion
  - 9.3.1 Steps 1 and 2: Search and Insert
  - 9.3.2 Step 3: Rebalance
  - 9.3.3 Symmetric Case
- 9.4 Deletion
  - 9.4.1 Step 1: Search
  - 9.4.2 Step 2: Delete
  - 9.4.3 Step 3: Rebalance
  - 9.4.4 Step 4: Finish Up
  - 9.4.5 Symmetric Case
- 9.5 Testing

8.7 Testing | Table of Contents | 9.1 Data Types