Quick Sort: Advantages
Quick Sort: Advantages
situations as it is not difficult to implement. It is a good general purpose sort and it consumes
Advantages
This algorithm has been subjected to a thorough mathematical analysis, a very precise
Disadvantages
complicated.
It is fragile, i.e. a simple mistake in the implementation can go unnoticed and cause it to
perform badly.
Quick sort works by partitioning a given array A[p ... r] into two non-empty sub array A[p ...
q] and A[q+1 ... r] such that every key in A[p ... q] is less than or equal to every key in A[q+1 ...
r].
Then, the two sub-arrays are sorted by recursive calls to Quick sort. The exact position of the
partition depends on the given array and index q is computed as a part of the partitioning
procedure.
Note that to sort the entire array, the initial call should be Quick-Sort (A, 1, length[A])
As a first step, Quick Sort chooses one of the items in the array to be sorted as pivot. Then, the
array is partitioned on either side of the pivot. Elements that are less than or equal to pivot will
move towards the left, while the elements that are greater than or equal to pivot will move
Analysis
The worst case complexity of Quick-Sort algorithm is O(n2). However using this technique, in