Question: Implement both bogosort and bombsort. When shuffling the array in bogosort, use python s random.shuffle ( . . . ) to shuffle your array. When

Implement both bogosort and bombsort.
When shuffling the array in bogosort, use pythons random.shuffle(...) to shuffle your array. When choosing an element in the array to bomb in bombsort, use pythons ran-dom.randint(...) or random.randrange(...) to select an element. Run bogosort 10000 times on unordered arrays of size [0,5], where each element is a distinct integer, i.e. no duplicates. Count the number of iterations it takes for bogosort to successfully sort the array with each run. Use your results to calculate the expected number of iterations it takes to sort the array using bogosort for each of those sizes.
Run bombsort 50000 times for similarly created arrays of size [0,10] and count the
number of iterations it takes for each run of the algorithm. Use your results to calculate the expected number of iterations it takes to sort the array using bombsort for each of those sizes. Hard code your results for the respective sorting algorithm in an a array as the return values of bogoOutput and bombOutput, where the ith element in the returned array is the expected number of iterations it takes to sort a list of size i with the respective algorithm.
Submit your file containing all your simulating work, but comment out any code other than bogoOutput and bombOutput
Use the following template to creat the above
import random
def bogoOutput():
return [0,0,0,0,0,0]
def bombOutput():
return [0,0,0,0,0,0,0,0,0,0,0]
def main():
return
if __name__=='__main__':
main()

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!