i (partition boundary): -1
j (scanner): 0
≤ Pivot Zone
0 elements
> Pivot Zone
0 elements
📚 Quick Sort Partition (Lomuto)
Partition rearranges elements around a pivot:
- Choose pivot (usually last element)
- Maintain partition index i (boundary of smaller elements)
-
Scan with j: if arr[j] ≤ pivot, swap arr[i+1] with arr[j], increment
i
- Finally, place pivot at i+1
- Result: all elements ≤ pivot on left, > pivot on right