Explanation

- **Quick Sort** is another divide-and-conquer sorting algorithm. It works by selecting a pivot element and partitioning the array into two subarrays — elements less than the pivot and elements greater than the pivot. The subarrays are then sorted recursively.

-

  • Steps:

    • Select a pivot element from the array.
    • Partition the array into two subarrays: one with elements smaller than the pivot, and one with elements greater than the pivot.
    • Recursively apply the same procedure to the two subarrays.
    • Combine the sorted subarrays to get the final sorted array.
  • Time Complexity:

    • Best Case, Average Case: O(n log n)
    • Worst Case (when the pivot is poorly chosen): O(n^2)