Email : info@mdjakarianur.com

|

Contact : +88 01840-713661 (WhatsApp)

Quick Sort Algorithms

Quick Sort Algorithm

QuickSort is a sorting algorithm based on the Divide and Conquer that picks an element as a pivot and partitions the given array around the picked pivot by placing the pivot in its correct position in the sorted array.

 

How does QuickSort Algorithm work?

QuickSort works on the principle of divide and conquer, breaking down the problem into smaller sub-problems.

There are mainly three steps in the algorithm:

  1. Choose a Pivot: Select an element from the array as the pivot. The choice of pivot can vary (e.g., first element, last element, random element, or median).
  2. Partition the Array: Rearrange the array around the pivot. After partitioning, all elements smaller than the pivot will be on its left, and all elements greater than the pivot will be on its right. The pivot is then in its correct position, and we obtain the index of the pivot.
  3. Recursively Call: Recursively apply the same process to the two partitioned sub-arrays (left and right of the pivot).
  4. Base Case: The recursion stops when there is only one element left in the sub-array, as a single element is already sorted.

 

One response to “Quick Sort Algorithms”

  1. Stan Store Avatar

    I am really inspired together with your writing skills as smartly
    as with the layout to your weblog. Is that this a paid subject
    matter or did you customize it yourself? Either way keep up the excellent quality
    writing, it is uncommon to see a nice weblog like this one
    today. Fiverr Affiliate!

Leave a Reply

Your email address will not be published. Required fields are marked *