Why it matters
Balanced trees are common but complex. Treap provides simple correct implementation.
Advertisement
The architecture
Insertion: BST insert; rotate to restore heap property.
Delete: rotate leaf down; remove.
Advertisement
How it works end to end
Split / merge: primary treap operations. Enable set-like operations in O(log n).
Implicit treap: implicit keys enable dynamic array with O(log n) operations.
Applications: dynamic set, order statistics, sequence with modifications.