Input:
algorithm quicksort(A, lo, hi) is if lo >= hi || lo < 0 then return p := partition(A, lo, hi) quicksort(A, lo, p - 1) quicksort(A, p + 1, hi) algorithm partition(A, lo, hi) is pivot := A[hi] i := lo - 1 for j := lo to hi - 1 do if A[j] <= pivot then i := i + 1 swap A[i] with A[j] i := i + 1 swap A[i] with A[hi] return i
Ps =
123
Pn =
123
SNR =
123
algorithm quicksort(arrayToSort, lowerIndex, higherIndex) is if lowerIndex >= higherIndex || lowerIndex < 0 then return partitionIndex := partition(arrayToSort, lowerIndex, higherIndex) quicksort(arrayToSort, lowerIndex, partitionIndex - 1) quicksort(arrayToSort, partitionIndex + 1, higherIndex) algorithm partition(arrayToSort, lowerIndex, higherIndex) is pivot := arrayToSort[higherIndex] currentIndex := lowerIndex - 1 for nextIndex := lowerIndex to higherIndex - 1 do if arrayToSort[nextIndex] <= pivot then currentIndex := currentIndex + 1 swap arrayToSort[currentIndex] with arrayToSort[nextIndex] currentIndex := currentIndex + 1 swap arrayToSort[currentIndex] with arrayToSort[higherIndex] return currentIndex
Ps =
123
Pn =
123
SNR =
123
Output:
Δ =
123
≈
123
%