sorting-visualiser/Algorithms/quicksort.js
//Implement recursion for unsorted left and right halves until whole array is sorted
Implement recursion for unsorted left and right halves until whole array is sorted
Implement recursion for unsorted left and right halves until whole array is sorted
function quickSort(array, left, right) {
    let index;
    if (array.length > 1) {
        index = partition(array, left, right);  
        if (left < index - 1) { 
            quickSort(array, left, index -1);   
        }
        if (index < right) {    
            quickSort(array, index, right);     
        }
    }
    return array;
}
function quickSort ( array , left , right ) { let index ; if ( array . length > 1 ) { index = partition ( array , left , right ) ; if ( left < index - 1 ) { quickSort ( array , left , index - 1 ) ; } if ( index < right ) { quickSort ( array , index , right ) ; } } return array ; }
Implement recursion for unsorted left and right halves until whole array is sorted
Implement recursion for unsorted left and right halves until whole array is sorted
//index of left pointer is returned from partition function //we use this index to divide the array and then perform quick sort again on the divided sections. //if the index is not yet at the left most element //perform quicksort on that section //if the index is not yet at the right most element //perfrom quicksort on that section