Quick Sort Visualizer with Recursion Tree
See how Quick Sort partitions the array recursively - first element as pivot
Array Size: 6Comparisons: 0Swaps: 0
Recursion Tree
Tree will appear during sorting
Pending
Partitioning
Partitioned
Sorted
Active
Array Visualization
10
[0]5
[1]2
[2]3
[3]14
[4]16
[5]Unsorted
Pivot
Comparing
Swapping
Sorted
🎯 Quick Sort Strategy:
- Pick Pivot: Choose first element as pivot
- Partition: Rearrange so ≤ pivot on left, > pivot on right
- Recurse: Repeat on left and right partitions
- Combine: No merge needed - sorted in place!
// Quick Sort with First Element as Pivot
// Time: O(n log n) average, O(n²) worst case
// Space: O(log n) for recursion stack
// In-place: Yes | Stable: No
public static void quickSort(int[] arr, int low, int high) {
if (low < high) {
int pi = partition(arr, low, high);
quickSort(arr, low, pi - 1); // Sort left
quickSort(arr, pi + 1, high); // Sort right
}
}