Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using this code from PYTHON: Attached you will find a pre-writtenPython program called Sort Timer and an Excel spreadsheet called Sort Compare. Modify the Sort

Using this code from PYTHON: Attached you will find a pre-writtenPython program called "Sort Timer" and an Excel spreadsheet called "Sort Compare". Modify the "Sort Timer" program to collect the data to complete the spreadsheet. Adjust the "size" variable in the program to the sizes indicated in the spreadsheet. Replace the Selection sort method in the program with the code for the other sort methods as needed. REMEMBER, you do not need to write or retype the various sort methods. All of the sort methods except for the Radix sort are provided in the zip file of the sample programs for the book (in the "Getting Started" section of the course). The Radix sort will be developed in the weekly discussion. Round all times to the nearest second.

import random import time import sys

sys.setrecursionlimit(2000)

def main():

size = 500 list = [] for i in range(size): list.append(random.randint(0, 100000 - 1))

print("Starting Sort ...") startTime = time.time() selectionSort(list) endTime = time.time() print("Exection time for Selection Sort with", size, "values is: ", endTime - startTime)

# The function for sorting the numbers def selectionSort(list): for i in range(len(list) - 1): # Find the minimum in the list[i..len(list)-1] currentMin = list[i] currentMinIndex = i

for j in range(i + 1, len(list)): if currentMin > list[j]: currentMin = list[j] currentMinIndex = j

# Swap list[i] with list[currentMinIndex] if necessary; if currentMinIndex != i: list[currentMinIndex] = list[i] list[i] = currentMin

main()

The Excel spreadsheet named Sort Compare.xlsx looks as follows:

Sort Methods

Array size selection bubble merge quick heap raidx
5,000
10,000
15,000
20,000
25,000
30,000

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 2 Lnai 9285

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Joao Gama ,Alipio Jorge ,Carlos Soares

1st Edition

3319235249, 978-3319235240

More Books

Students also viewed these Databases questions