Menu

[Solved]Need Create Bubble Sort Python Repeats 10 Times Random Numbers Calculates Time Run Average Q37043478

I need to create a Bubble Sort in Python that repeats 10 timeswith random numbers and calculates the time for each run and thenthe average time. I have figured out how to put in the randomnumbers but have not gotten it to run 10 times or figure out how totime each run as well as the average. My code is as follows

import randomimport time def bubbleSort(alist): for passnum in range(len(alist)-1,0,-1): for i in range(passnum): if alist[i]>alist[i+1]: temp = alist[i] alist[i] = alist[i+1] alist[i+1] = tempalist = random.sample(range(1, 100), 10)bubbleSort(alist)print(alist)

Expert Answer


Answer to I need to create a Bubble Sort in Python that repeats 10 times with random numbers and calculates the time for each run … . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *