Answered step by step
Verified Expert Solution
Link Copied!

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,

image text in transcribed
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 + 1,- . - n] is a uniformly random permutation of the numbers contained in the subarray. What happens after the final iteration?) . 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

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamental financial accounting concepts

Authors: Thomas P. Edmonds, Frances M. Mcnair, Philip R. Olds, Edward

8th edition

978-0078025365

Students also viewed these Mathematics questions