From 9f03e18184bb13c8480f4371963efb0469e8717f Mon Sep 17 00:00:00 2001 From: MrWeast Date: Fri, 1 Dec 2023 15:50:50 -0500 Subject: [PATCH] Update radix_sort.py added a random array to test the sort --- src/python/radix_sort.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/python/radix_sort.py b/src/python/radix_sort.py index 0d88722..b15dd4a 100644 --- a/src/python/radix_sort.py +++ b/src/python/radix_sort.py @@ -1,3 +1,5 @@ +import random + def radix_sort(arr): # Find the maximum number to know the number of digits max_num = max(arr) @@ -33,11 +35,23 @@ def counting_sort(arr, exp): def main(): + print("Fixed Testing Array") arr = [170, 2, 45, 75, 75, 90, 802, 24, 2, 66] print("Unsorted array:", arr) radix_sort(arr) print("Sorted array:", arr) + print("Random Testing Array") + arr = [] + for i in range(0,10): + arr.append(random.randint(0,20)) + print("Unsorted array:", arr) + radix_sort(arr) + print("Sorted array:", arr) + + + + if __name__ == "__main__": main()