I'm using the following hash function
function hash_djb2($str){
$hash = 5381;
$length = strlen($str);
for($i = 0; $i < $length; $i++) {
$hash = (($hash << 5) + $hash) + ord(strtolower($str[$i])) - 96;
}
return $hash;
}
Am I supposed to return $hash
or $hash % $numBuckets
where $numBuckets
is the number of buckets in the hash table?
The former would return really large numbers and make hash collision impossible while the latter returns only values between 0 and $numBuckets
-1 but makes hash collision possible