Berg v1.1.0 Berg
A Minimum Heap for Integers

Link to this section Summary
Functions
A heap alongside an element where that element would be the smallest if it were in the heap
A heap with the same elements as the list in question
A heap whose smallest element is the minimum of the element in question and the smallest element of the heap in question
A list in ascending order (w/ all the same elements as the heap)
The smallest element of the heap
The heap in question w/o the smallest element
A Heap w/ just one element
A zero heap
Predicate: is this the zero heap?
Link to this section Types
An Element (just an Integer)
A Minimum Heap
Link to this section Functions
A heap alongside an element where that element would be the smallest if it were in the heap
Example
iex> l = [42, 16, 8, 4, 15, 23]
iex> h = Berg.heapify l
iex> {t, e} = Berg.extract h
iex> Berg.listify t
[8, 15, 16, 23, 42]
iex> e
4
A heap with the same elements as the list in question
A heap whose smallest element is the minimum of the element in question and the smallest element of the heap in question
Example
iex> l = [16, 8, 15, 23]
iex> h = Berg.heapify l
iex> i = h |> Berg.insert(4) |> Berg.insert(42)
iex> Berg.root(i)
4
A list in ascending order (w/ all the same elements as the heap)
The smallest element of the heap
Example
iex> l = [42, 16, 8, 4, 15, 23]
iex> h = Berg.heapify l
iex> Berg.root h
4
The heap in question w/o the smallest element
Example
iex> l = [42, 16, 8, 4, 15, 23]
iex> h = Berg.heapify l
iex> t = Berg.trunk h
iex> Berg.listify(t)
[8, 15, 16, 23, 42]
A zero heap