Quick sort in pseudocode
A recursive function that picks a pivot, partitions the array into smaller and larger parts around it, then calls itself on each part until the array is sorted.
Understanding Quick sort in pseudocode in VCE Software Development U3O1
What it does: Partitioning compares each item with the pivot and sends smaller values to the smaller array. The base case returns the array unchanged, which stops the recursion. The function needs an array parameter so it knows which data to sort. A header with no parameter has nothing to partition. Quick sort begins by choosing a pivot. Everything else is partitioned around that pivot. The recursive calls quickSort(smaller) and quickSort(larger) sort each part separately. The pivot belongs between the sorted smaller and larger parts, or it disappears from the output.
Common mistakes: The loop should only go over the rest of the items. Looping over the whole array compares the pivot with itself and puts it in a part as well. It should be: for each x in rest. The function header has no parameter, so the function has no array to sort and the pivot line cannot work. It should be: function quickSort(array).
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 142–155) and word search (Modules 142–166).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
quickSort(array)Fill in the Blanks
Spot the Error
Student with a class code? Join your class →