Skip to main content

Quick Sort (Divide & Conquer)

Learn Quick Sort (Divide & Conquer) (Divide & Conquer, Data Structures & Algorithms) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Quick Sort as Divide and Conquer Quick sort does its work in the divide step. Partition chooses a pivot and rearranges the array so that smaller elements are left of it and larger ones right of it; the pivot is then already in its final place. Both sides are sorted recursively, and there is no combine step at all. With balanced splits the cost is O(n log n) , with the sorting done in place.

More lessons in Divide & Conquer