An alternative permutation algorithm is to fill the array a from a[0] to a[n-1], as follows. To fill a[i], generate random numbers until you get one that has not been used previously. Use an array of Booleans to perform that test. Give an analysis of the expected running time (this is tricky) and then write a program that compares this running time with both your analysis and the routine shown in Figure 7.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here