Algorithms and OOD (CSC 207 2014S) : EBoards

CSC207.01 2014S, Class 28: Quicksort



Upcoming Work


Aspects of QuickSort

So what is the pivot?

Is QuickSort stable?

More importantly, it's memory efficient.


Let's organize this array:

[slots are numbered 0 – 11]
lb = 0; ub = 12
a|l|p|h|a|b|e|t|i|c|a|l [we pick b as our pivot]

lb = 1; ub = 12

If an element is > b we lower ub, if element is < b we raise lb

We keep sorting, get to

ub == lb == 3

So we recurse over the first four elements and the rest of the list, and the list is eventually sorted!

Copyright (c) 2013-14 Samuel A. Rebelsky.

Creative Commons License

This work is licensed under a Creative Commons Attribution 3.0 Unported License. To view a copy of this license, visit or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.