Red-black trees have many cases, especially for deletion. The AA-tree (named after its inventor, Arne Andersson, 1993) is a red-black tree with one extra restriction that removes most of those cases. Instead of colours it stores a level in each node, and only two simple operations, skew and split, keep it balanced.
Levels and horizontal links
A link from a node to a right child on the same level is called a horizontal link (it corresponds to a red child in a red-black tree). The rules say: horizontal links may only go to the right (no red left children), and two horizontal links may not follow each other (no red-red).
Skew and split
Skew removes a left horizontal link with a single right rotation.
Split removes two consecutive right horizontal links with a single left rotation; the middle node moves up one level.
Insertion adds the new key as a leaf at level 1, then on the way back up the search path calls skew and then split at each node. Deletion is similar, with level decreases followed by a few skews and splits.
Treaps
A treap (“tree” + “heap”) stores in every node a key and a randomly chosen priority. It is a binary search tree with respect to the keys and a heap with respect to the priorities: each node’s priority is at least as large as its parent’s (so the smallest priority is at the root). Insertion adds the node as a BST leaf and then rotates it up while its priority is smaller than its parent’s. Because the priorities are random, the tree behaves like a BST built from keys in random order: expected height O(logn), with very simple code.
Comparing the balanced search trees
Tree
Balance information
Guarantee
Best for
AVL
Height or balance factor
Worst case O(logn), height ≤ 1.44 log n
Search-heavy, in memory
Red-black
1 colour bit
Worst case O(logn), height ≤ 2 log n
Update-heavy, libraries
AA-tree
Level (small integer)
Worst case O(logn)
Simple code for a red-black-like tree
Splay
None
Amortized O(logn)
Repeated access to the same keys
Treap
Random priority
Expected O(logn)
Simple randomised balancing
B-tree
Key counts per node
Worst case O(logmn)
Disks and databases
Key takeaways
AA-tree: levels instead of colours; horizontal links only to the right, never two in a row.
Skew = right rotation removing a left horizontal link; split = left rotation, middle node up a level.
Insertion: add a level-1 leaf, then skew and split back up the path.
Treap: BST on keys + heap on random priorities: expected O(logn).
Practice questions
Answer on paper first, then check. The explanation matters more than the letter you chose.
Question 6 · short answer
Insert 1, 2, 3 into an empty AA-tree and explain each skew and split.
Show worked answer
Insert 1: a leaf at level 1. Insert 2: 2 > 1, so 2 is 1’s right child at level 1, a single right horizontal link (allowed); skew and split do nothing. Insert 3: 3 becomes 2’s right child at level 1. On the way back up, at node 1 there is no left horizontal link (no skew), but 1 → 2 → 3 are two consecutive right horizontal links, so split at 1: a left rotation makes 2 the root and 2 moves up to level 2, with children 1 and 3 at level 1. Final tree: 2/2(1/1, 3/1).
MCA Online notes are made for reading on screen. Open https://mcastudy.online/mcs-208/advanced-trees/aa-trees-and-treaps/ to read this page.