Solution
Correct answer is Option 3
Explanation:Quick sort is a Divide and Conquer algorithm.
It picks an element as a pivot and partitions the given array around the picked pivot.
In Quick sort algorithm, partitioning of the list is performed using following steps...
- Step 1 - Consider the first element of the list as pivot (i.e., Element at first position in the list).
- Step 2 - Define two variables i and j. Set i and j to first and last elements of the list respectively.
- Step 3 - Increment i until list[i] > pivot then stop.
- Step 4 - Decrement j until list[j] < pivot then stop.
- Step 5 - If i < j then exchange list[i] and list[j].
- Step 6 - Repeat steps 3,4 & 5 until i > j.
- Step 7 - Exchange the pivot element with list[j] element
Worst Case : O(n2)
Best Case : O (n log n)
Average Case : O (n log n)