Heap Sort
This article has content about max heap and minimum in heap in data structures.
They are clearly explained in the presentation with suitable examples.
Max Heap
Store data in ascending order
Has property of
A[Parent(i)] ≥ A[i]
Min Heap
Store
...See more
data in descending order
Has property of
A[Parent(i)] ≤ A[i]
Algorithm
Add the new element to the next available position at the lowest level
Restore the max-heap property if violated
General strategy is percolate up (or bubble up): if the parent of the element is smaller than the element, then interchange the parent and child.
OR
Restore the min-heap property if violated
General strategy is percolate up (or bubble up): if the parent of the element is larger than the element, then interchange the parent and child.
Delete max
Copy the last number to the root ( overwrite the maximum element stored there ).
Restore the max heap property by percolate down.
Delete min
Copy the last number to the root ( overwrite the minimum element stored there ).
Restore the min heap property by percolate down.
A sorting algorithm that works by first organizing the data to be sorted into a special type of binary tree called a heap
Views: 3318
Added: 4 years ago
Answer the Question