Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Programming Interview Questions

Name: Anonymous 2011-05-22 16:08

You have a stream of numbers that you can see one at a time. With uniform probability, select only one of these numbers. That is, each number in the stream has the same probability of being selected. You cannot just store the entire stream to an array or read through the stream twice.

Name: Anonymous 2011-05-22 16:32

>>2
Shut the fuck up, bitch.  You are SO FUCKING WRONG. 

>>1
Ok, nigger, what you FUCKING DO is create an ARRAY of INTEGERS that has ONE ELEMENT for EACH POSSIBLE NUMBER in the STREAM.  You then READ THROUGH the ENTIRE GOD DAMN STREAM.  Increase the ELEMENT WITHIN THE DAMN ARRAY that corresponds with the NUMBER READ FROM THE STREAM.  You'll then have a GOD DAMN FUCKING HISTOGRAM OF ALL READ NUMBERS and can select a RANDOM NUMBER with SHIT PROBABILITES ADJUSTED FOR FREQUENCY OF OCCURRENCE.  FUCK.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List