This is an old revision of the document!
Lab 08 - Heaps
Heaps
Binary Heaps are binary trees with the following properties:
I. forall nodes n: if c is a child of n, then n.value >= c.value
II. the tree is almost complete (missing elements are possible only on the last level)
15 / \ 9 5 / \ / 2 3 1
Heap representation using an array:
15 9 5 2 3 1
This corresponds to a BF traversal of the tree, and it guarantees that the children nodes corresponding to v[i] are v[2i + 1] and v[2i + 2]
1 Basic operations. Implement and analyse the complexity for the following operations:
1.1 empty_heap() - creates an empty heap