treaps
A treap is a randomized binary search tree that maintains both a binary search tree property on keys and a heap property on priorities. Each node stores a key and a randomly assigned priority; priorities are independent and drawn from a uniform distribution. The tree is organized so that keys in the left subtree are less than the node’s key, keys in the right subtree are greater, and the node’s priority is not smaller than the priorities of its children (a max-heap convention is common).
Insertion begins by performing a standard BST insert based on the key, assigning a random priority to
Treaps offer expected logarithmic time for insertions, deletions, and searches, with an average height of O(log
Common applications include maintaining dynamic ordered sets and performing order-statistics or range queries without complex rebalancing