News for hackers. Stuff that matters.
Re:Write a hash table in C by pieguy on Wednesday August 23, 2017 @06:41PM (#15085827)
"(long)pow(a, len_s - (i+1))" is both inefficient and inaccurate. You should store the current power in a variable which you multiply by 'a' and reduce by 'm' on each iteration.

Also, your double hashing scheme has a bug. You identified that it's problematic if hash_b returns 0, but adding 1 to the result doesn't actually solve anything, because now you have the same problem if hash_b returns num_buckets-1.

There are no comments on this comment yet.