A detailed video about the implementation of quicksort with a hacker rank question at the end to solidify the concept.
Problem:-https://www.hackerrank.com/challenges/quicksort1/problem
Code:-https://github.com/pulkit-nehra05/Code
What is Quick Sort?
Quick Sort is also based on the concept of Divide and Conquer Technique where the real work happens when we divide the arrays into subarrays. It is divided into three main parts:-
1. Elements that are less than the pivot.
2. The Pivot Element(Central).
3. Elements that are greater than the pivot.
How Does it work?
1. After selecting an element as pivot, which is the last index of the array in our case, we divide the array for the first time.
2. In quick sort, we call this partitioning. It is not simply breaking down of array into 2 subarrays, but in case of partitioning, the array elements are so positioned that all the elements smaller than the pivot will be on the left side of the pivot and all the elements greater than the pivot will be on the right side of it.
3. And the pivot element will be at its final sorted position.
4. The elements to the left and right, may not be sorted.
5. Then we pick subarrays, elements on the left of pivot, and elements on the right of the pivot, and we perform partitioning on them by choosing a pivot in the subarrays.
Timestamps:
0:00 Introduction.
02:06 Code walkthrough.
08:32 HackerRank problem with the solution.
13:02 Hackerank code explanation
20:10 Result
#quicksort
#quicksort in java
#hackerrank