A Heap where value of value of parent.
Often used as a Sorting Algorithm
Algorithm
Assumes input is a unsorted array. Uses algorithms:
build-max-heap: create Max-Heap from unsorted arrayheapify: create Max-Heap, assuming part of array is sorted Algorithm is:
- Create max heap with
build-max-heap - Until list is sorted:
- Swap item at the start of heap list with item at end
- Run
heapifyto convert back to max-heap form