The following code fragment (adapted from a Java programming book) creates a random permutation of the integers from 0 to n − 1. Determine the order of growth of its running time as a function of n. Compare its order of growth with the shuffling code in Section 1.4.
int[] a = new int[n];boolean[] taken = new booleanfn];int count = 0;while (count < n){ int r = StdRandom.uniform(n); if (!taken[r]) { a[r] = count; taken[r] = true; count++; }}
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.