Quick Sort
Quick Sort
Quick sort is a highly efficient sorting algorithm and is based on partitioning of array of data into smaller arrays. A large array is
partitioned into two arrays one of which holds values smaller than the specified value, say pivot, based on which the partition is made
and another array holds values greater than the pivot value.
Quicksort partitions an array and then calls itself recursively twice to sort the two resulting subarrays. This algorithm is quite efficient
for large-sized data sets as its average and worst-case complexity are O(n2), respectively.
The pivot value divides the list into two parts. And recursively, we find the pivot for each sub-lists until all lists contains only one
element.
https://www.tutorialspoint.com/data_structures_algorithms/quick_sort_algorithm.htm 1/3
7/30/2021 Data Structure and Algorithms - Quick Sort - Tutorialspoint
while True do
while A[++leftPointer] < pivot do
//do-nothing
end while
end while
https://www.tutorialspoint.com/data_structures_algorithms/quick_sort_algorithm.htm 2/3
7/30/2021 Data Structure and Algorithms - Quick Sort - Tutorialspoint
swap leftPointer,right
return leftPointer
end function
if right-left <= 0
return
else
pivot = A[right]
partition = partitionFunc(left, right, pivot)
quickSort(left,partition-1)
quickSort(partition+1,right)
end if
end procedure
To know about quick sort implementation in C programming language, please click here .
https://www.tutorialspoint.com/data_structures_algorithms/quick_sort_algorithm.htm 3/3