MCPcopy Create free account
hub / github.com/chaharnishant11/CodeIn10DSA / partition

Function partition

Sorting/Code/quickSort.py:15–31  ·  view source on GitHub ↗
(elements, start, end)

Source from the content-addressed store, hash-verified

13 quick_sort(elements, pi+1, end)
14
15def partition(elements, start, end):
16 pivot_index = start
17 pivot = elements[pivot_index]
18
19 while start < end:
20 while start < len(elements) and elements[start] <= pivot:
21 start+=1
22
23 while elements[end] > pivot:
24 end-=1
25
26 if start < end:
27 swap(start, end, elements)
28
29 swap(pivot_index, end, elements)
30
31 return end
32
33
34if __name__ == '__main__':

Callers 1

quick_sortFunction · 0.70

Calls 1

swapFunction · 0.70

Tested by

no test coverage detected