Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3. Using the radix sort algorithm, implement the code below IN PYTHON and add this to the code: generate a list of 100 random numbers

3. Using the radix sort algorithm, implement the code below IN PYTHON and add this to the code: generate a list of 100 random numbers from 1000 possible values. Print the list. Run the algorithm and make sure you show the list after each pass (in other words, if there are, say, three digits max in each number, then your output should show the original list, the list after the units digit is processed, the list after the tens digit is processed, and then the final sorted list.) Commentwill the code run successfully if all of the digits are not the same length? In other words, if I have values of, say, 76 and 124, do I need to make the 76 be represented as 076 or will the code handle it correctly?

Here is the radix sort code:

from llistqueue import Queue

from array import Array

def radixSort( intList, numDigits):

binArray = Array (10)

for k in range(10):

binArray[k]= Queue()

column = 1

for d in range(numDigits):

for key in intList:

digit = (key//column)%10

binArray[digit].enqueue(key)

i = 0

for bin in binArray:

while not bin.isEmpty():

intList[i] = bin.dequeue()

i += 1

column *=10

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 1 Lncs 13426

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124227, 978-3031124228

More Books

Students also viewed these Databases questions

Question

Question Can a Roth IRA invest in stock of the IRA owners business?

Answered: 1 week ago