Re:Help wanted: Google hiring in 2011
by nostrademons on Wednesday January 26, 2011 @01:55AM
(#2142432)
That's not quite random, because you're selecting items with probability 1/RAND_MAX. The elements beyond RAND_MAX will never be selected.
My shot: pick some random number, go through that many linked list items and return the item you're at. Only needs to store the current item pointer and the random number. Maybe I'm missing something simple, though to be fair, it's a lot harder to answer these kinds of questions when you're under the scrutiny of an interview.