A friend of mine is working on a shuffling algorithm. Here’s what he’s got:
int *shuffle2(int numItems)
{
//int index[numItems];
int *randomIndex = malloc(sizeof(int)*numItems);
int i,j;
for(i = 0; i < numItems; i++)
{
//index[i] = 0;
randomIndex[i] = -1;
}
int randomNum = rand()%numItems;
for(j = 0; j < numItems; j++)
{
while(randomIndex[randomNum] != -1)
{
randomNum = rand()%numItems;//random(0, numItems-1);
}
//index[randomNum] = 1;
randomIndex[randomNum] = j;
}
return randomIndex;
}
It has certain problems. I’ll cover those later. After I figure them out.
But until then, I will study Chi-Squared tests.
