Need Help ?

Home / Expert Answers / Other / A permutation p of the numbers {1, 2, ..., n} is called a derangement if p[i] is not equal to i for

A permutation p of the numbers {1, 2, ..., n} is called a derangement if p[i] is not equal to i for ...


A permutation p of the numbers {1, 2, ..., n} is called a derangement if p[i] is not equal to i for all i. For example, p = [2, 3, 1] is a derangement but q = [2, 1, 3] is not, since q[3] = 3. (Permutations here are arrays indexed as p[1..n].) (a) Give an O(n) expected-time algorithm to compute a uniform random derangement of {1, 2, ..., n}. Do not give code. (Hint: the number of derangements of {1, 2, ..., n} is the integer closest to n!/e, where e = 2.718... is Euler's constant.) (b) Prove your algorithm is correct. (c) Prove your algorithm has expected running time O(n).



Radioactive Tutors

Radio Active Tutors is a freelance academic writing assistance company. We provide our assistance to the numerous clients looking for a professional writing service.

NEED A CUSTOMIZE PAPER ON THE ABOVE DETAILS?
Order Now


OR

Get outline(Guide) for this assignment at only $10

Get Outline $10

**Outline takes 30 min - 2 hrs depending on the complexity and size of the task
Designed and developed by Brian Mubichi (mubix)
WhatsApp