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
- Base condition: Return the array as it is if the array length is equal to 1.
- Identify the pivot value
- Get all the elements less than the pivot value on one side.
- Get all the elements greater than the pivot value on another side.
- Repeat steps 2,3 & 4
- Return final sorted array
Click below link to view the pictorial representation of how the algorithm works
Source: https://www.geeksforgeeks.org/
Implementation in JavaScript
below is the result
Hope this is useful, will catch you soon on my next post!
Happy learning!
Thanks,
Sudharsanan Ravichandran
Top comments (0)