October 2025
Intermediate to advanced
485 pages
13h 2m
English
Like a red-black tree, a treap is a type of binary search tree (BST), but a treap follows a unique set of rules beyond the behavior of a traditional BST. The name “treap” is a combination of the words “tree” and “heap,” and you’ll see shortly what heaps have to do with treaps, other than the fact that they rhyme.
Treaps themselves come in various flavors, not all of which are self-balancing. Our focus in this chapter is on the randomized treap since this is the kind of treap that serves as a self-balancing tree. To save ink, though, I’ll refer to randomized treaps simply as treaps since that’s the only type of treap we’ll be dealing with here.
Treaps and red-black trees share certain things in common:
They are ...
Read now
Unlock full access