Overview
A treap stores keys in search-tree order and random priorities in heap order, giving expected logarithmic height.
Combines binary search tree ordering with random heap priorities.
Compact metadata for implementation and discovery.
A treap stores keys in search-tree order and random priorities in heap order, giving expected logarithmic height.
Quick facts
Runtime and memory behavior at a glance.
Best
O(log n)
Average
O(log n)
Worst
O(n)
Space
O(n)
key_left < key_node < key_right and priority_parent <= priority_childMaintains search ordering and heap ordering at the same time.
Show the structure layout and how operations move through or update it.
Treap should be used with the assumptions and tradeoffs of randomized Search Tree in mind.
What each reference supports for this entry.
Original reference for treaps/randomized search trees, heap priorities, and expected logarithmic operations.
Open sourceGood next jumps from the relationship graph, ranked for useful discovery.
Treaps and skip lists both use randomization to maintain expected logarithmic ordered-set operations.
Treap is a data-structure variant of Binary Search Tree with different update or query tradeoffs.