Heaps, or priority queues, are collections of elements from an ordered set where besides checking for emptiness and inserting elements
is_empty <- function(x) UseMethod("is_empty")
insert <- function(x, elm) UseMethod("insert")
we can also access and delete the smallest element:1
find_minimal <- function(heap) UseMethod("find_minimal")
delete_minimal <- function(heap) UseMethod("delete_minimal")
Heaps do not necessarily contain sets. It is possible for heaps to have multiple elements with the same value.
In addition to these operations, we will also require that we can merge two heaps:
merge <- ...