// random number generator; generates random permutations // maximum length of permutation is 10000 #include #include #include #define maxSize 10000 #define NumberPermutations 20 template bool SSearch(T a[], const T& x, int n) {// Search the unordered list a[0:n-1] for x. // Return true if found; return false otherwise. int i; for (i = 0; i < n && a[i] != x; i++); if (i == n) return false; return true; } template void InsertionSort(T a[], int n) {// Sort a[0:n-1]. for (int i = 1; i < n; i++) { // insert a[i] into a[0:i-1] T t = a[i]; int j; for (j = i-1; j >= 0 && t < a[j]; j--) a[j+1] = a[j]; a[j+1] = t; } } int* randomPermutation(int Size) {// generate a random permutation of 0, 1, 2, ......, Size-1 int a[maxSize], i, tempNext; bool found = true; for(i=0; i> length; cout << "generate " << NumberPermutations << " permutations" << endl; cout << endl; randomize(); for (int i=0; i