Consider the following algorithm for generating a uniform random permutation:
PERMUTE-IN-CYCLES(A)
n = A.length
let B[1...n] be a new array
offset = RANDOM(1,n)
for index = 1 to n
pos = index + offset
if pos > n
pos = pos - n
B[pos] = A[index]
return B
a) (7 pts) Show that each element A[index] has a probability of ending up in any particular position in B.
b) (3 pts) Explain why the resulting permutation is not uniformly random.