Quick Sort Algorithm

Computer Science: OCR A Level, topic 8.1.11

Quick Sort Algorithm

The quick sort algorithm is a sorting algorithm that uses an element known as a pivot and works around it by dividing the elements.

Divide and conquer paradigm

Divide and conquer paradigm

  • Quick sort is based on the divide and conquer paradigm.
  • Quick sort consists of two phases:
  • 1- Partition phase
  • 2- Sorting phase
Rearranging the array

Rearranging the array

  • Quick sort selects an element as a pivot.
  • It rearranges the array in a way that all the elements to the left of the pivot will be smaller than the pivot.
  • All the elements to the right will be greater than the pivot.
  • Then quick sort recursively quick sort left and right subarrays.
Stopping criteria

Stopping criteria

  • Stopping criteria:
  • 1- Every element is an old pivot
  • 2- A list of length 1

Test yourself on Quick Sort Algorithm

  • What are the two phases of Quick sort?

  • What does the quick sort algorithm recursively sorts?

Practise this topic for free