|Don't ask to ask, just ask|
how are the number of buckets in a perl hash chosenby david2008 (Scribe)
|on Jun 09, 2014 at 07:37 UTC||Need Help??|
david2008 has asked for the
wisdom of the Perl Monks concerning the following question:
Hi all, I take now a refresher on algorithms with the coursera course https://class.coursera.org/algo-005 given by Tim Roughgarden.
There is a whole week devoted to hash tables and bloom filters.
He mentioned there that the numbers of buckets in a hash should be a prime number, which is not close to a power of 2 or 10.
I use hashes in a perl on a daily basis and wanted to see how the theory is translated to the real world :-).
Firs i created a small hash %c= (a=>3,4=>5)
and saw that the number of buckets are 8. Then i wrote a small code:
and got the result 7391/16384.
Apparently the number of buckets are not prime and are divided by two.
I know from my experience that the perl hashes work amazingly fast and efficient. So how can this be explained?