0Pricing
C Academy · Lesson

Quicksort

Divide and conquer.

Divide and Conquer

Quicksort is a divide-and-conquer sort. It picks a pivot, partitions the array so smaller elements go left and larger go right, then recursively sorts each side.

Average time is O(n log n).

The Partition Step

The key idea is partitioning: rearrange the array around a pivot so that everything left of the pivot is smaller and everything right is larger. The pivot then sits in its final sorted position.

All lessons in this course

  1. Bubble and Insertion Sort
  2. Quicksort
  3. Mergesort
  4. Using qsort
← Back to C Academy