Wednesday

April 23, 2014

April 23, 2014

Posted by **Nathan** on Saturday, February 23, 2013 at 8:52pm.

while not isSorted(input):

shuffle(input)

If we feed bogosort a shuffled array of length n of unique items the distribution of the number of times

bogosort checks if the array is sorted (henceforth called `an iteration') is Geo( 1/n! ).

(a) What is the expected number of iterations it will take bogosort to run for an array of k unique

values?

(b) When writing this question I ran bogosort many times. I wanted to nd a case where I was using

an array of 5 items and it took bogosort more than 500 iterations to sort the array. What is the

probability that if I run bogosort on an array of 5 items that bogosort will take more than 500

iterations to sort it? (Write out the sum you would need to evaluate and evaluate the sum. Write

the answer to 4 decimal places)

(c) When feeding in a shued array of 3 unique values into bogosort the probability that it takes less

than or equal to 2 iterations to sort the array is 11/36. If I use bogosort to sort 20 random arrays

each with 3 unique values - What is the distribution of the number of arrays it takes less than or

equal to 2 iterations to sort?

(d) What is the probability that for the same situation as in the previous part that exactly 2 out of the

20 arrays took less than or equal to 2 iterations to sort?

**Related Questions**

computers - How can you write a sorting algorithm for three intergers in simple ...

sorting - sorting the same set in different ways

computers - The recursive algorithm of the 4th Section of the chapter "...

Computer programming - Sorting is a common operation used in programming. ...

programming - Write an algorithm that converts a decimal number to binary. Then...

Algorithm - write a pseudo code algorithm that will accept 20 numbers and finds ...

english - please help me!!!! Put the sizes on the uniforms while sorting them ...

programming - Write an algorithm that prints the factorial for the first 20 even...

mat 156 - The following algorithm give a correct answer 488 +_65_ 5^1 5^1 3 ...

physics - n this problem, we will carry out some steps of the quantum factoring ...