Time and Space Complexity

For Worst Case - It occurs when the pivot element is at extreme end of the array that is sorted. The time complexity of quick sort for this case is O(n^2).

For Best Case - It occurs when the pivot element is at middle. The time complexity of quick sort for this case is O(n*log n).

For Average Case - It occurs in different situations. The time complexity of quick sort for this case is O(n*log n).

 

The space complexity of quick sort is O(log n). 

Discussion

8

0