Quick Sort, as the name suggests, sorts any list very quickly. Quick sort is not stable search, but it is very fast and requires very less aditional space. It is based on the rule of Divide and Conquer(also called partition-exchange sort). This algorithm divides the list into three main parts :
- Elements less than the Pivot element
- Pivot element
- Elements greater than the pivot element
The next step is to call this function recursively.It will return one number if only one member is left in any of the three parts.
Complexity Analysis of Quick Sort
Worst Case Time Complexity : O(n2)Best Case Time Complexity : O(n log n)
Average Time Complexity : O(n log n)
Space Complexity : O(n log n)
- Space required by quick sort is very less, only O(n log n) additional space is required.
- Quick sort is not a stable sorting technique, so it might change the occurence of two similar elements in the list while sorting.
Comments
Post a Comment
Comment on articles for more info.