create()
, destroy()
, … maintenance
operations.
add(data)
and data remove()
manipulation operations.
size()
, empty()
, data top()
, … query
operations.
heap::create(T a[], unsigned n)
heap::create(heap h1, heap h2)
heap::merge(heap h)
i = count++ d[i] = e while i ≠ 0 p = (i - 1)/2 if d[p] ≥ d[i], break swap(d[p], d[i]) i = p |
|
heapsort(a[], n) for i = 1 to n - 1 bubble-up(a, i) for i = n - 1 to 1 swap(a[0], a[i]) bubble-down(i)