MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / radixSort

Function radixSort

Python/radix_sort.py:31–51  ·  view source on GitHub ↗
(inputArray)

Source from the content-addressed store, hash-verified

29 return outputArray
30
31def radixSort(inputArray):
32 # Step 1 -> Find the maximum element in the input array
33 maxEl = max(inputArray)
34
35 # Step 2 -> Find the number of digits in the `max` element
36 D = 1
37 while maxEl > 0:
38 maxEl /= 10
39 D += 1
40
41 # Step 3 -> Initialize the place value to the least significant place
42 placeVal = 1
43
44 # Step 4
45 outputArray = inputArray
46 while D > 0:
47 outputArray = countingSortForRadix(outputArray, placeVal)
48 placeVal *= 10
49 D -= 1
50
51 return outputArray
52
53input = [2,20,61,997,1,619]
54print(input)

Callers 1

radix_sort.pyFile · 0.85

Calls 2

countingSortForRadixFunction · 0.85
maxFunction · 0.50

Tested by

no test coverage detected