1.1 KiB
1.1 KiB
title | date | draft | description | tags | categories | series | favorite | disable_feed | |||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Treap, revisited | 2024-07-27T14:12:27+01:00 | false | An even simpler BST |
|
|
|
false | false |
My [last post]({{< relref "../2024-07-20-treap/index.md" >}}) about the Treap showed an implementation using tree rotations, as is commonly done with AVL Trees and Red Black Trees.
But the Treap lends itself well to a simple and elegant implementation with no tree rotations. This makes it especially easy to implement the removal of a key, rather than the fiddly process of deletion using tree rotations.
Implementation
All operations on the tree will be implemented in terms of two fundamental
operations: split
and merge
.
We'll be reusing the same structures as in the last post, so let's skip straight
to implementing those fundaments, and building on them for insert
and
delete
.