Question: Using python: Modify the Sort Timer program to collect the data to complete the spreadsheet. Adjust the size variable in the program to the sizes

Using python: 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.Round all times to the nearest second:

import random import time import sys sys.setrecursionlimit(2000) def main(): size = 300000 list = [] for i in range(size): list.append(random.randint(0, 100000 - 1)) print("Starting Sort ...") startTime = time.time() quickSort(list) endTime = time.time() print("Exection time for Selection Sort with", size, "values is: ", endTime - startTime) # The function for sorting the numbers def quickSort(list): quickSortHelper(list, 0, len(list) - 1) def quickSortHelper(list, first, last): if last > first: pivotIndex = partition(list, first, last) quickSortHelper(list, first, pivotIndex - 1) quickSortHelper(list, pivotIndex + 1, last) # Partition list[first..last] def partition(list, first, last): pivot = list[first] # Choose the first element as the pivot low = first + 1 # Index for forward search high = last # Index for backward search while high > low: # Search forward from left while low  pivot: high -= 1 # Swap two elements in the list if high > low: list[high], list[low] = list[low], list[high] while high > first and list[high] >= pivot: high -= 1 # Swap pivot with list[high] if pivot > list[high]: list[first] = list[high] list[high] = pivot return high else: return first main()

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

Sort Methods Array Size Selection Bubble Quick Heap Radix 5000 10000 150000 200000 250000 300000 Sort Methods Array Size Selection Bubble Quick Heap Radix 5000 10000 150000 200000 250000 300000

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!