Why it matters
Treaps are simple randomized balanced BSTs. Foundation for persistent structures.
Advertisement
The architecture
Each node: key + random priority.
BST on keys.
Max-heap on priorities.
Rotations maintain.
Advertisement
How it works end to end
Random priorities on insert.
Rotations when priority violates heap.
Expected height O(log n).