Divide & Conquer: Quick Sort
HardAcc. 72.2%
+50 XP 25
The Pivot Strategy (QuickSort)
QuickSort is a high-speed "Divide and Conquer" algorithm. It picks a "Pivot" point and splits the world into two sides: those smaller than the pivot and those larger. By doing this recursively, the array is sorted at lightning speed.
The Assignment
Your mission is to implement the recursive QuickSort protocol. Your function receives data.
- Use a helper function for the partition logic (Lomuto Partition).
- Choose the last element as the pivot.
- Partition the array such that all smaller elements move to the left of the pivot.
- Recursively sort the left and right halves.
- Print the final sorted result (space-separated).
01EXAMPLE 1
Input
[10, 7, 8, 9, 1, 5]Output
1 5 7 8 9 10Explanation: Sorted using recursive partitioning.
Constraints
- O(n log n) average time complexity.
- Must use recursion.
AlgorithmsSortingRecursion
JavaScriptSystem handles I/O — write your function only
Loading...
1 Hidden
Input Arguments
data[10,7,8,9,1,5]
Expected Output
1 5 7 8 9 10
Click RUN to test your solution