Racket package implementing balanced binary search trees using treaps.
This function takes a number v, and returns a treap containing that value.
> (make-treap 1)
#<treap>
> (list-treap (make-treap 2))
'(1)
This function consumes a treap t, and a number v, and returns t after v is inserted.
> (list-treap (insert-treap (make-treap 2) 3))
'(2 3)
> (list-treap (insert-treap (make-treap 2) 1))
'(1 2)
This function consumes a treap t and a zero-based index i, and returns the i'th largest element of t
> (lookup-treap (make-treap 2) 0)
2
> (lookup-treap (insert-treap (make-treap 2) 3) 1)
3
> (lookup-treap (insert-treap (make-treap 2) 1) 1)
2
This function consumes a treap t and a value v and returns t with v deleted
> (list-treap (delete-treap (make-treap 2) 2))
'()
> (list-treap (delete-treap (insert-treap (make-treap 2) 3) 3))
'(2)
> (list-treap (delete-treap (insert-treap (make-treap 2) 3) 2))
'(3)
Searches a treap t for a value v; returns true if v is found, false otherwise
> (search-treap (make-treap 2) 2)
#t
> (search-treap (make-treap 2) 3)
#f