Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Consider the following algorithm to generate a uniformly random permutation of natural numbers 1, 2, ...n . Start with the sorted array. At each iteration,
Consider the following algorithm to generate a uniformly random permutation of natural numbers 1, 2, ...n . Start with the sorted array. At each iteration, pick A[1] (that is the first element) and insert it at any of the 11 positions chosen uniformly at random. If it is inserted at A[i], then the index of all numbers from i down to 2 is decremented by 1. Repeat this process till 11 1 becomes the first element and then the above operation is done one final time. o Prove that on termination, the algorithm indeed produces a uniformly random permutation (Hint : Try to prove that at any iteration, ifj is the position of number n 1, then the subarrayA[j,j + 1,- - - n] is a uniformly random permutation of the numbers contained in the subarray. What happens after the final iteration?) o What is the expected number of operations performed by this algorithm (Hint : Use number n 1 as a tracker!)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started