Professional Documents
Culture Documents
Heap sort
• Algorithm for Heap sort
• Visualization of Heap sort
References
The fundamentals of quick sort are:
Quick Sort is a Divide and Conquer algorithm.
It picks an element as pivot and partitions the given
array around the picked pivot.
There are many different versions of quicksort that
pick pivot in different ways. In this presentation we
have chosen the last element as the pivot.
Continue partitioning the array using the pivot until
there is one element left.
STEP 1. Choosing the pivot
Example : 8, 3, 25, 6,10
Here the last element 10 is the pivot.
STEP 2. Partitioning
Entries less than the pivot are placed on the left.
Entries greater than the pivot are placed on the right.
Example : 3,8,6≤10≤25
STEP 3. Recursively quick sort the left and right parts.
Example:3,8,⑥≤10≤25 [ Now 6 is the pivot on the left part ]
3≤6≤8≤10≤25
So the final sorted array:3,6,8,10,25
10,90,40,30,50
10,40,30 90
Pivot
Partition
Partition around 50
around 30
40
10
10 12
4 7 6
• Method : It is an Method : It is a
efficient version of divide and conquer
selection sort. technique.
Complexity: Complexity:
Best Case:Ω(n log n) Best Case:θ(n log n)
Worst Case :O(n log n) Worst Case :θ (n2)
http://www.geeksforgeeks.org/sorting-algorithm
https://www.programiz.com/dsa/heap-sort
www.algolist.net/Algorithms/Sorting/Quicksort