Skip to content

Latest commit

 

History

History

QuickSort

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Algorithm

quickSort(array, low, high):
    if (low < high){
        pi = partition(array, low, high);
        quickSort(arr, low, pi);
        quickSort(arr, pi + 1, high);
    }

partition(arr, low, high):
    pivot = array[low];
    i = low;
    j = high;
    while (i < j){
        do{
            i += 1;
        } while(array[i] <= pivot);
        do{
            j += 1;
        } while(array[j] > pivot);
        if (i < j){
            swap(array[i], array[j]);
        }
    }
    swap(array[low], array[j]);
    return j;

Complexity

  • Time:
    • Worst Case: formula
    • Average Case: formula
    • Best Case: formula
  • Space:
    • Worst Case: formula