Algorithm

 

 

 

 

Quick Sort

 

Quick Sort is an algorithm to arrange the elements in an array(or list) in certain order (increasing or decreasing order). It is almost impossible to describe in words only.

Assuming that we want to sort in increasing order as an example, the key concept of this algorithm is to partition an array into two parts in such a way that all the elements in the left side of the partition is smaller than the pivot and all the elements on the right side of the partition is greater than the pivot. Apply the same process to the left side partition and right side partition and repeat this until every elements is sorted. This process can be illustrated as follows.

 

Now you need to understand the detailed of partitioning process. You would see a lot of YouTubes about this partitioning process. I personally recommend you to watch the video at Ref [1].

 

NOTE 1 : The green element indicates the element which is at the right position in the ordered list and no further sorting required.

NOTE 2 : As shown in the illustration, the mechanism of the Quick Sort based on recursion of a same operation over and over. So it will be helpful if you are familiar with the implementation of recursive routine at least in any one of the language you are good at (See an example of Recursion in C).

 

 

 

 

Reference :

 

[1] Quicksort: Partitioning an array (YouTube)