of size . As long as the array is not sorted, in each step, a subset of is randomly permuted. This subset is optimally chosen each time so that is sorted in the least amounts of steps. What is the expected value of the total number of times this operation needs to be done in order to sort ?
You are given an array
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Since the vector A = ( 8 , 3 , 2 , 4 , 5 , 6 , 7 , 1 , 9 , 1 0 , 1 1 , 1 2 , 1 3 ) has only the underlined elements out of order, we just need to choose and permutate subsets {8,1} and {3,2}. For both of them, the probability of getting the right order follows a geometric distribution Geo ( p = 2 1 ) , so the expected number of steps to get one of them in order is E { 8 , 1 } = E { 3 , 2 } = p 1 = 2 . Evenutally, the expected number of steps to get the whole array sorted is E = E { 8 , 1 } + E { 3 , 2 } = 4 .