Please enable JavaScript.
Coggle requires JavaScript to display documents.
Heaps and heapsort - Coggle Diagram
Heaps and heapsort
A heap can be defined as a binary tree with keys assigned to its
nodes, one key per node, provided the following two conditions are met:
The shape property—the binary tree is essentially complete (or simply complete),
i.e., all its levels are full except possibly the rightmost leaves may be missing
The parental dominance or heap property—the key in each node is greater
than or equal to the keys in its children. (This condition is considered automatically satsfied for all leaves)
Differently from Binary Search Trees, in a heap, there is no left-to-right order in key values
Heap properties
There exists exactly one essentially complete binary tree with n nodes. Its
height is equal to [log2 n]
-
-
It is convenient to store the heap’s elements in
positions 1 through n of such an array, leaving H[0] either unused or putting there a sentinel whose value is greater than every element in the heap
-
The data structure called the “heap” is definitely NOT a disordered pile of items
as the word’s definition in a standard dictionary might suggest.
It is actually a clever, partially ordered data structure that is especially suitable for implementing priority queues
A priority queue is a multiset of items with an orderable
characteristic called an item’s priority, with the following operations:
-
-
-
The heap is also the data structure that serves as a cornerstone of
a theoretically important sorting algorithm called heapsort
-
-