Every Day We’re Shuffling…

Published Mar 1, 2015 by Pillow Computing Consortium at /blog/2015-02-28-every-day-were-shuffling/

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.

 

Lane Kolbly

Story logo

© 2022 Pillow Computing Consortium