@Dave sir, I didn't get your logic. Can you please elaborate it?

On Sun, Aug 19, 2012 at 4:08 AM, Dave <dave_and_da...@juno.com> wrote:

> @Navin: Here is the algorithm:
>
> Save the first word.
> For i = 2, 3, ..., n = number of words in the file
>     replace the saved word with the i-th word with probability 1/i.
> When EOF is reached, every word in the file will have probability 1/n of
> being the saved word. Print it.
>
> Dave
>
> On Saturday, August 18, 2012 1:28:56 AM UTC-5, Navin Kumar wrote:
>
>> Print a *Random word* from a file. Input is "path to a file",
>>
>> constraints- No extra memory like hashing etc. All the words in the file
>> should have equal probability.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/HxO-wNzEP9gJ.
>
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to