MCPcopy Create free account
hub / github.com/covscript/covscript / quicksort

Function quicksort

tests/benchmark.py:177–195  ·  view source on GitHub ↗
(a, left, right)

Source from the content-addressed store, hash-verified

175
176# ---------------------- Quicksort Benchmark ----------------------
177def quicksort(a, left, right):
178 if right <= left:
179 return
180 i, j, pivot = left - 1, right, a[right]
181 while True:
182 while True:
183 i += 1
184 if i >= len(a) or a[i] >= pivot:
185 break
186 while True:
187 j -= 1
188 if j < 0 or a[j] <= pivot:
189 break
190 if i >= j:
191 break
192 a[i], a[j] = a[j], a[i]
193 a[i], a[right] = a[right], a[i]
194 quicksort(a, left, j)
195 quicksort(a, i + 1, right)
196
197
198def test_quicksort(num_tests, length):

Callers 1

test_quicksortFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_quicksortFunction · 0.68