You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using a random number generator which can uniformly generate a interger between 1 and a self-defined upper bound k. Design an algorithm to randomly permute the size-n array num consisted of consecutive positive intergers from 1 to n.
Solution:
The idea is to scan through all positions of the size-n array and give the current number at each position equal probabilities to be at all positions including its current position.