Question: Using python show how to time a selection sort using the code below: # The function for sorting elements in ascending order def selectionSort(list): for

Using python show how to time a selection sort using the code below:

# The function for sorting elements in ascending order def selectionSort(list): for i in range(len(list) - 1): # Find the minimum in the lst[i : len(lst)] currentMin, currentMinIndex = list[i], i for j in range(i + 1, len(list)): if currentMin > list[j]: currentMin, currentMinIndex = list[j], j

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

list = [300000, 5000, 150000, 250000, 10000, 200000] selectionSort(list) print("Selection sorted list: ",list)

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!