Skip to content

Latest commit

 

History

History
37 lines (34 loc) · 1006 Bytes

README.md

File metadata and controls

37 lines (34 loc) · 1006 Bytes

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