Skip to content

Commit

Permalink
added radix sort for simulation (keon#351)
Browse files Browse the repository at this point in the history
  • Loading branch information
NormalB authored and goswami-rahul committed Jun 13, 2018
1 parent 2f361dd commit 27d53fb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion algorithms/sort/radix_sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
radix sort
complexity: O(nk) . n is the size of input list and k is the digit length of the number
"""
def radix_sort(arr):
def radix_sort(arr, simulation=False):
is_done = False
position = 1

iteration = 0
if simulation:
print("iteration",iteration,":",*arr)

while not is_done:
queue_list = [list() for _ in range(10)]
is_done = True
Expand All @@ -22,5 +26,9 @@ def radix_sort(arr):
arr[index] = num
index += 1

if simulation:
iteration = iteration + 1
print("iteration",iteration,":",*arr)

position *= 10
return arr

0 comments on commit 27d53fb

Please sign in to comment.