Skip to content

Commit 27d53fb

Browse files
NormalBgoswami-rahul
authored andcommitted
added radix sort for simulation (keon#351)
1 parent 2f361dd commit 27d53fb

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

algorithms/sort/radix_sort.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22
radix sort
33
complexity: O(nk) . n is the size of input list and k is the digit length of the number
44
"""
5-
def radix_sort(arr):
5+
def radix_sort(arr, simulation=False):
66
is_done = False
77
position = 1
88

9+
iteration = 0
10+
if simulation:
11+
print("iteration",iteration,":",*arr)
12+
913
while not is_done:
1014
queue_list = [list() for _ in range(10)]
1115
is_done = True
@@ -22,5 +26,9 @@ def radix_sort(arr):
2226
arr[index] = num
2327
index += 1
2428

29+
if simulation:
30+
iteration = iteration + 1
31+
print("iteration",iteration,":",*arr)
32+
2533
position *= 10
2634
return arr

0 commit comments

Comments
 (0)