public static Object[] algorithm1(int N)
{
//DO NOT COUNT IN opCount
long opCount = 0;
String fn = "f(N) = [answer]";
String On = "O(N) = [answer]";
//BEGIN opCounts
int[] arr = new int[N];
Random randGen = new Random(123456789);
return new Object[] { arr, new String[] { fn, On, opCount + "" } };
}
Use the following method to fill the array For each position in the array, generate a random number between zero and N If N = 10, random numbers should be 0-9 Check if that random number is used in any previous position in the array If it is used anywhere else, generate a new number and try again If it is not used anywhere else, place it into the position and move forward
Aucun commentaire:
Enregistrer un commentaire