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 random.randint or random.randrange to select an element. Run bogosort times on unordered arrays of size where each element is a distinct integer, ie 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 times for similarly created arrays of size 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
def bombOutput:
return
def main:
return
if namemain:
main
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
