Prévia do material em texto
Chapter 1.3, Problem 1E Step-by-step solution Step 1 of 1 Algorithm for Random Permutation Consider an array arrayl of n integers. Now, shuffle the array to get the random numbers. Here input parameter is n and output parameter is arrayl. Algorithm to shuffle the array is as follows: for i=1ton //Assign values 1 to n for i=1to n-1 //Loop to shuffle the values //Swap with some value in array as the //function rand (i,n) returns a random number between i to n. }