Data Structure

Quick Sort

Learn data structure by example of quick sort algorithm

4/22/2021
0 views
quick-sort-algorithm.cC
function quicksort(array)
    if length(array) > 1
        pivot = select any element of array
        left = first index of array
        right = last index of array
        while left <= right
            while array[left] < pivot
                left = left + 1
            while array[right] > pivot
                right = right - 1
            if left <= right
                swap array[left] with array[right]
                left = left + 1
                right = right - 1
        quicksort(array from first index to right)
        quicksort(array from left to last index)
quick sort algorithmdata structurealgorithmquick sort

Loading comments...

Related Examples