Unit 7Advanced Trees
Follows IGNOU MCS-208, Unit 7
A binary search tree lets us search, insert and delete in time proportional to its height. If the tree stays short (height about ), these operations are very fast; if it becomes a long chain, they are as slow as a linked list. This unit starts with the binary search tree and then studies the main ways of keeping search trees fast: AVL trees and red-black trees (balanced binary trees), B-trees (wide trees for disks and databases), splay trees (self-adjusting trees) and AA-trees (a simpler red-black tree).
In this unit you will learn to
- define a binary search tree correctly and search, insert and find the minimum and maximum in it;
- delete a node from a BST in all three cases;
- explain AVL balance factors and perform LL, RR, LR and RL rotations;
- insert into and delete from an AVL tree, keeping it balanced;
- define a B-tree of order m, search it, and build one by insertion with splits;
- explain splaying (zig, zig-zig, zig-zag) and amortized analysis;
- state the red-black tree properties and follow the insertion fix-up cases;
- explain the levels, skew and split of an AA-tree, and what a treap is.
Sections in this unit
- 7.1Binary Search Trees: Definition, Search and InsertionThe correct definition of a binary search tree, its traversals, searching, finding the minimum and maximum, insertion and why height matters.12 min
- 7.2Deleting a Node from a Binary Search TreeThe three cases of BST deletion (leaf, one child, two children), the inorder successor, and a tested C implementation.10 min
- 7.3AVL Trees and RotationsHeight-balanced AVL trees, balance factors, and the four rotation cases LL, RR, LR and RL that restore balance.10 min
- 7.4AVL Insertion, Deletion and ApplicationsInserting into and deleting from an AVL tree with rebalancing on the way back up, a tested implementation, and where AVL trees are used.12 min
- 7.5B-Trees: Structure and SearchWhy disks need wide, shallow trees, the definition of a B-tree of order m with its key and child limits, and searching a B-tree.11 min
- 7.6B-Tree Insertion, Deletion and ApplicationsB-tree insertion with node splits that grow the tree at the root, a worked order-5 example, deletion by borrowing and merging, and uses.16 min
- 7.7Splay TreesSelf-adjusting splay trees, the zig, zig-zig and zig-zag steps, top-down and bottom-up splaying, and amortized O(log n) cost.14 min
- 7.8Red-Black TreesThe red-black properties and black-height, left and right rotations, the three insertion fix-up cases, and an outline of deletion.20 min
- 7.9AA-Trees and TreapsAA-trees as simplified red-black trees with levels, horizontal links, the skew and split operations, and treaps that combine a BST with a heap.12 min