[algogeeks] Fwd: Big-O Cheat Sheet

2013-05-05 Thread Wladimir Tavares
http://bigocheatsheet.com/ Wladimir Araujo Tavares Fiz uma faculdade! Só não fiz a segunda porque acabaram os tijolos. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an

[algogeeks] 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.

2013-05-05 Thread Nishant Pandey
Hi Guys, In this problem i am wondering how it will be done without extra memory space, though we can easily do it with hashing and random funcs(). Is there any solution for this , Please help. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group.

[algogeeks] Re: 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.

2013-05-05 Thread Dave
@Nishant: I'm assuming that you don't know the number of words in the file, and that you don't want to store them all. Here is an algorithm that requires you to store only two words and an integer. Assume double function random() returns a uniformly distributed random number = 0.0 and 1.0.