GNU libavl 2.0.3
Short Contents
GNU libavl 2.0.3
Preface
1 Introduction
2 The Table ADT
3 Search Algorithms
4 Binary Search Trees
5 AVL Trees
6 Red-Black Trees
7 Threaded Binary Search Trees
8 Threaded AVL Trees
9 Threaded Red-Black Trees
10 Right-Threaded Binary Search Trees
11 Right-Threaded AVL Trees
12 Right-Threaded Red-Black Trees
13 BSTs with Parent Pointers
14 AVL Trees with Parent Pointers
15 Red-Black Trees with Parent Pointers
Appendix A References
Appendix B Supplementary Code
Appendix C GNU Free Documentation License
Appendix D Glossary
Appendix E Answers to All the Exercises
Appendix F Catalogue of Algorithms
Appendix G Index
Table of Contents
GNU libavl 2.0.3
Preface
Acknowledgements
Contacting the Author
1 Introduction
1.1 Audience
1.2 Reading the Code
1.3 Code Conventions
1.4 Licenses
2 The Table ADT
2.1 Informal Definition
2.2 Identifiers
2.3 Comparison Function
2.4 Item and Copy Functions
2.5 Memory Allocation
2.6 Creation and Destruction
2.7 Count
2.8 Insertion and Deletion
2.9 Assertions
2.10 Traversers
2.10.1 Constructors
2.10.2 Manipulators
2.11 Table Headers
2.12 Additional Exercises
3 Search Algorithms
3.1 Sequential Search
3.2 Sequential Search with Sentinel
3.3 Sequential Search of Ordered Array
3.4 Sequential Search of Ordered Array with Sentinel
3.5 Binary Search of Ordered Array
3.6 Binary Search Tree in Array
3.7 Dynamic Lists
4 Binary Search Trees
4.1 Vocabulary
4.1.1 Aside: Differing Definitions
4.2 Data Types
4.2.1 Node Structure
4.2.2 Tree Structure
4.2.3 Maximum Height
4.3 Rotations
4.4 Operations
4.5 Creation
4.6 Search
4.7 Insertion
4.7.1 Aside: Root Insertion
4.8 Deletion
4.8.1 Aside: Deletion by Merging
4.9 Traversal
4.9.1 Traversal by Recursion
4.9.2 Traversal by Iteration
4.9.2.1 Improving Convenience
4.9.3 Better Iterative Traversal
4.9.3.1 Starting at the Null Node
4.9.3.2 Starting at the First Node
4.9.3.3 Starting at the Last Node
4.9.3.4 Starting at a Found Node
4.9.3.5 Starting at an Inserted Node
4.9.3.6 Initialization by Copying
4.9.3.7 Advancing to the Next Node
4.9.3.8 Backing Up to the Previous Node
4.9.3.9 Getting the Current Item
4.9.3.10 Replacing the Current Item
4.10 Copying
4.10.1 Recursive Copying
4.10.2 Iterative Copying
4.10.3 Error Handling
4.11 Destruction
4.11.1 Destruction by Rotation
4.11.2 Aside: Recursive Destruction
4.11.3 Aside: Iterative Destruction
4.12 Balance
4.12.1 From Tree to Vine
4.12.2 From Vine to Balanced Tree
4.12.2.1 General Trees
4.12.2.2 Implementation
4.12.2.3 Implementing Compression
4.13 Aside: Joining BSTs
4.14 Testing
4.14.1 Testing BSTs
4.14.1.1 BST Verification
4.14.1.2 Displaying BST Structures
4.14.2 Test Set Generation
4.14.3 Testing Overflow
4.14.4 Memory Manager
4.14.5 User Interaction
4.14.6 Utility Functions
4.14.7 Main Program
4.15 Additional Exercises
5 AVL Trees
5.1 Balancing Rule
5.1.1 Analysis
5.2 Data Types
5.3 Operations
5.4 Insertion
5.4.1 Step 1: Search
5.4.2 Step 2: Insert
5.4.3 Step 3: Update Balance Factors
5.4.4 Step 4: Rebalance
5.4.5 Symmetric Case
5.4.6 Example
5.4.7 Aside: Recursive Insertion
5.5 Deletion
5.5.1 Step 1: Search
5.5.2 Step 2: Delete
5.5.3 Step 3: Update Balance Factors
5.5.4 Step 4: Rebalance
5.5.5 Step 5: Finish Up
5.5.6 Symmetric Case
5.6 Traversal
5.7 Copying
5.8 Testing
6 Red-Black Trees
6.1 Balancing Rule
6.1.1 Analysis
6.2 Data Types
6.3 Operations
6.4 Insertion
6.4.1 Step 1: Search
6.4.2 Step 2: Insert
6.4.3 Step 3: Rebalance
6.4.4 Symmetric Case
6.4.5 Aside: Initial Black Insertion
6.4.5.1 Symmetric Case
6.5 Deletion
6.5.1 Step 2: Delete
6.5.2 Step 3: Rebalance
6.5.3 Step 4: Finish Up
6.5.4 Symmetric Case
6.6 Testing
7 Threaded Binary Search Trees
7.1 Threads
7.2 Data Types
7.3 Operations
7.4 Creation
7.5 Search
7.6 Insertion
7.7 Deletion
7.8 Traversal
7.8.1 Starting at the Null Node
7.8.2 Starting at the First Node
7.8.3 Starting at the Last Node
7.8.4 Starting at a Found Node
7.8.5 Starting at an Inserted Node
7.8.6 Initialization by Copying
7.8.7 Advancing to the Next Node
7.8.8 Backing Up to the Previous Node
7.9 Copying
7.10 Destruction
7.11 Balance
7.11.1 From Tree to Vine
7.11.2 From Vine to Balanced Tree
7.12 Testing
8 Threaded AVL Trees
8.1 Data Types
8.2 Rotations
8.3 Operations
8.4 Insertion
8.4.1 Steps 1 and 2: Search and Insert
8.4.2 Step 4: Rebalance
8.4.3 Symmetric Case
8.5 Deletion
8.5.1 Step 1: Search
8.5.2 Step 2: Delete
8.5.3 Step 3: Update Balance Factors
8.5.4 Step 4: Rebalance
8.5.5 Symmetric Case
8.5.6 Finding the Parent of a Node
8.6 Copying
8.7 Testing
9 Threaded Red-Black Trees
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
10 Right-Threaded Binary Search Trees
10.1 Data Types
10.2 Operations
10.3 Search
10.4 Insertion
10.5 Deletion
10.5.1 Right-Looking Deletion
10.5.2 Left-Looking Deletion
10.5.3 Aside: Comparison of Deletion Algorithms
10.6 Traversal
10.6.1 Starting at the First Node
10.6.2 Starting at the Last Node
10.6.3 Starting at a Found Node
10.6.4 Advancing to the Next Node
10.6.5 Backing Up to the Previous Node
10.7 Copying
10.8 Destruction
10.9 Balance
10.10 Testing
11 Right-Threaded AVL Trees
11.1 Data Types
11.2 Operations
11.3 Rotations
11.4 Insertion
11.4.1 Steps 1–2: Search and Insert
11.4.2 Step 4: Rebalance
11.5 Deletion
11.5.1 Step 1: Search
11.5.2 Step 2: Delete
11.5.3 Step 3: Update Balance Factors
11.5.4 Step 4: Rebalance
11.6 Copying
11.7 Testing
12 Right-Threaded Red-Black Trees
12.1 Data Types
12.2 Operations
12.3 Insertion
12.3.1 Steps 1 and 2: Search and Insert
12.3.2 Step 3: Rebalance
12.4 Deletion
12.4.1 Step 2: Delete
12.4.2 Step 3: Rebalance
12.4.3 Step 4: Finish Up
12.5 Testing
13 BSTs with Parent Pointers
13.1 Data Types
13.2 Operations
13.3 Insertion
13.4 Deletion
13.5 Traversal
13.5.1 Starting at the First Node
13.5.2 Starting at the Last Node
13.5.3 Starting at a Found Node
13.5.4 Starting at an Inserted Node
13.5.5 Advancing to the Next Node
13.5.6 Backing Up to the Previous Node
13.6 Copying
13.7 Balance
13.8 Testing
14 AVL Trees with Parent Pointers
14.1 Data Types
14.2 Rotations
14.3 Operations
14.4 Insertion
14.4.1 Steps 1 and 2: Search and Insert
14.4.2 Step 3: Update Balance Factors
14.4.3 Step 4: Rebalance
14.4.4 Symmetric Case
14.5 Deletion
14.5.1 Step 2: Delete
14.5.2 Step 3: Update Balance Factors
14.5.3 Step 4: Rebalance
14.5.4 Symmetric Case
14.6 Traversal
14.7 Copying
14.8 Testing
15 Red-Black Trees with Parent Pointers
15.1 Data Types
15.2 Operations
15.3 Insertion
15.3.1 Step 2: Insert
15.3.2 Step 3: Rebalance
15.3.3 Symmetric Case
15.4 Deletion
15.4.1 Step 2: Delete
15.4.2 Step 3: Rebalance
15.4.3 Step 4: Finish Up
15.4.4 Symmetric Case
15.5 Testing
Appendix A References
Appendix B Supplementary Code
B.1 Option Parser
B.2 Command-Line Parser
Appendix C GNU Free Documentation License
Appendix D Glossary
Appendix E Answers to All the Exercises
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Chapter 8
Chapter 9
Chapter 10
Chapter 11
Chapter 13
Chapter 14
Appendix F Catalogue of Algorithms
Binary Search Tree Algorithms
AVL Tree Algorithms
Red-Black Tree Algorithms
Threaded Binary Search Tree Algorithms
Threaded AVL Tree Algorithms
Threaded Red-Black Tree Algorithms
Right-Threaded Binary Search Tree Algorithms
Right-Threaded AVL Tree Algorithms
Right-Threaded Red-Black Tree Algorithms
Binary Search Tree with Parent Pointers Algorithms
AVL Tree with Parent Pointers Algorithms
Red-Black Tree with Parent Pointers Algorithms
Appendix G Index
GNU libavl 2.0.3
Preface
Introduction
The Table ADT
Search Algorithms
Binary Search Trees
AVL Trees
Red-Black Trees
Threaded Binary Search Trees
Threaded AVL Trees
Threaded Red-Black Trees
Right-Threaded Binary Search Trees
Right-Threaded AVL Trees
Right-Threaded Red-Black Trees
BSTs with Parent Pointers
AVL Trees with Parent Pointers
Red-Black Trees with Parent Pointers
References
Supplementary Code
GNU Free Documentation License
Glossary
Answers to All the Exercises
Catalogue of Algorithms
Index
Table of Contents
Preface