I think we have a simpler way for partition of an array: arr[] 1. Choose a pivot: p 2. Use two cursors L (left) that is the first index of array and R (right) is the last index. 3. Rule: while L = p (loop until we find an element that is less than pivot) 3.3. If L < R: swap(arr[L], arr[R]) 4. Return L (partition point) Then we call quickSort(arr, begin, mid - 1) and quickSort(arr, mid, end). With "begin" is the first index of array, "end" is the last index, "mid" = partition point.
@MineCrafterCity11 ай бұрын
I think this is isn't fully correct. You need to have a pivot and a "i" and "j" and you compare those with the pivot.
@geekific11 ай бұрын
Half of the video was dedicated to implement the method that plays around with the pivot. Check again!
@FluteVJ Жыл бұрын
Fantastic explanation. To improvise the performance we can avoid the swapping for the pivotIndexCounter == i. At 6:42 inside the if condition you can add the below code to do that. if(pivotIndexCounter==i) { pivotIndexCounter++; continue; }
@santhoshkumar1278 Жыл бұрын
Thanks for this video. The explanations for the partition call stack was really helpful in understanding the algorithm better.