DEV Community

Sudharsanan Ravichandran
Sudharsanan Ravichandran

Posted on

1 1

QuickSort

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

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay