Skip to content
StackDecode
Advanced data structuresExplained

Treap

A BST ordered by key and a heap ordered by random priority.

Time

O(log n) expected

Extra space

O(n)

Use it for

Simple balanced tree.

An animated walkthrough for this algorithm isn’t built yet. The summary above explains the idea; see the related animated algorithms below to practise the same technique.