Partition(a, m, p) v = a[m] i = m j = p repeat repeat i = i + 1 until a[i] > v repeat j = j - 1 until a[j] < v if i < j then Interchange(a, i, j) until i > j a[m] = a[j] a[j] = v return j Interchange(a, i, j) temp = a[i] a[i] = a[j] a[j] = temp QuickSort(a, p, q) if p < q then j = Partition(a, p, q + 1) QuickSort(a, p, j - 1) QuickSort(a, j + 1, q)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter