Quicksort picks a pivot, partitions the array so smaller elements are on the left and larger on the right, then recurses on each partition. It sorts in place, so its space overhead is just the recursion stack - O(log n) on average.
Quick sort partitions first, then recurses on both sidesThe pivot choice decides the running time. A good pivot splits the array evenly for O(n log n); a bad pivot (smallest or largest each time) gives O(n^2). Merge sort is immune to bad inputs but needs O(n) extra memory. Watch both on the same data and compare comparisons, swaps and the partition trace.