Partition: Tracing

  • Explain and trace the quicksort algorithm on a particular data sequence.

Exercise Trace the first pass of running quicksort (applying partitioning process) on the following sequence. Take the right-most element as pivot.

20, 13, 7, 71, 31, 10, 5, 50, 17 20, \space 13, \space 7, \space 71, \space 31, \space 10, \space 5, \space 50, \space 17

Solution
2013771311055017
5137713110205017
5137103171205017
5137101771205031

Items in bold indicate the elements which were swapped.