The document discusses the heap sort algorithm which has two steps: 1) Build a max heap from the input data in O(n) time by transforming it into a complete binary tree that satisfies the heap property. 2) Perform n deleteMax operations to extract the maximum element from the heap and place it in the sorted output, doing this in O(log(n)) time per operation for an overall time of O(nlog(n)).
9. AlgorithmStep 1. Build Heap – O(n)
- Build binary tree taking N items as input, ensuring the
heap structure property is held, in other words, build a
complete binary tree.
- Heapify the binary tree making sure the binary tree
satisfies the Heap Order property.
Step 2. Perform n deleteMax operations – O(log(n))
- Delete the maximum element in the heap – which is the
root node, and place this element at the end of the sorted
array.
10. AlgorithmStep 1. Build Heap – O(n)
- Build binary tree taking N items as input, ensuring the
heap structure property is held, in other words, build a
complete binary tree.
- Heapify the binary tree making sure the binary tree
satisfies the Heap Order property.
Step 2. Perform n deleteMax operations – O(log(n))
- Delete the maximum element in the heap – which is the
root node, and place this element at the end of the sorted
array.
23. Algorithm
Step 1. Build Heap – O(n)
- Build binary tree taking N items as input, ensuring the
heap structure property is held, in other words, build a
complete binary tree.
- Heapify the binary tree making sure the binary tree
satisfies the Heap Order property.
Step 2. Perform n deleteMax operations – O(log(n))
- Delete the maximum element in the heap – which is the
root node, and place this element at the end of the sorted
array.
26. Algorithm
Step 1. Build Heap – O(n)
- Build binary tree taking N items as input, ensuring the
heap structure property is held, in other words, build a
complete binary tree.
- Heapify the binary tree making sure the binary tree
satisfies the Heap Order property.
Step 2. Perform n deleteMax operations – O(log(n))
- Delete the maximum element in the heap – which is the
root node, and place this element at the end of the sorted
array.
36. Algorithm
Step 1. Build Heap – O(n)
- Build binary tree taking N items as input, ensuring the
heap structure property is held, in other words, build a
complete binary tree.
- Heapify the binary tree making sure the binary tree
satisfies the Heap Order property.
Step 2. Perform n deleteMax operations – O(log(n))
- Delete the maximum element in the heap – which is the
root node, and place this element at the end of the sorted
array.