The quicksort algorithm is typically solved as two methods (see reference program below – will be discussed in class):

a) The Partition method:

·      Finds the pivot

·      Moves the pivot to the appropriate cell in the array

·      Returns the pivot's index.

b) The Quicksort method: 

·      Calls the partition method and receives a new value of the pivot

·      Recursively calls the quicksort method on the sub-array to the left of the pivot

·      Recursively calls the quicksort method on the sub-array to the right of the pivot.

 

Program Code