QuickSort picks a pivot element, partitions the array so smaller elements are left and larger elements are right, then recursively sorts each side.
The idea:
Choose a pivot (often the last element).
Partition: rearrange so elements pivot are left, elements pivot are right.
Recursively sort left and right partitions.
Example for with pivot :
After partition: . Pivot is in its final position. Recursively sort and .
Unlike merge sort, quicksort does work before recursing (partition) rather than after (merge).