loading...

QuickSort

sudharsanansr profile image Sudharsanan Ravichandran ・1 min read

It's been a while since I posted, today we will discuss QuickSort.

Before that, if you haven't seen my last post. Click on the below link.

The topic for today is QuickSort!

  • Quicksort is a divide & conquer algorithm.
  • It uses recursion to sort the elements.
  • It considers pivot element as a base value and sorts rest of the elements.

Pseudocode

  1. Base condition: Return the array as it is if the array length is equal to 1.
  2. Identify the pivot value
  3. Get all the elements less than the pivot value on one side.
  4. Get all the elements greater than the pivot value on another side.
  5. Repeat steps 2,3 & 4
  6. Return final sorted array

Click below link to view the pictorial representation of how the algorithm works

Geeks For Geeks reference

Source: https://www.geeksforgeeks.org/

Implementation in JavaScript

QuickSort implementation in JS

below is the result

Result

Hope this is useful, will catch you soon on my next post!

Happy learning!

Thanks,
Sudharsanan Ravichandran

Posted on by:

sudharsanansr profile

Sudharsanan Ravichandran

@sudharsanansr

#Python #JS #Algorithms #DataStructures

Discussion

pic
Editor guide