MCPcopy Create free account
hub / github.com/BeeBombshell/Python-DSA / counting_Sort

Function counting_Sort

Sort-all/Radix.py:1–18  ·  view source on GitHub ↗
(array, exp1)

Source from the content-addressed store, hash-verified

1def counting_Sort(array, exp1):
2 n = len(arr)
3 output = [0] * (n)
4 count = [0] * (10)
5 for i in range(0, n):
6 index = (arr[i]/exp1)
7 count[int((index)%10)] += 1
8 for i in range(1,10):
9 count[i] += count[i-1]
10 i = n-1
11 while i>=0:
12 index = (arr[i]/exp1)
13 output[ count[ int((index)%10) ] - 1] = arr[i]
14 count[int((index)%10)] -= 1
15 i -= 1
16 i = 0
17 for i in range(0,len(arr)):
18 arr[i] = output[i]
19def radixSort(arr):
20 max1 = max(arr)
21 exp = 1

Callers 1

radixSortFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected