Open jmnyarega opened 5 years ago
function hash(string, arr) {
const H = 37; // hash value
let total = 0;
for (let i = 0; i < string.length; i++) {
total += H * total + string.charCodeAt(i);
}
total = total % arr.length;
return parseInt(total);
}
https://github.com/ligaroba/datastructures-and-algorithms/blob/7086cc6a286d80d9e7ffa5e1f56b75a6eb851f6b/Hashtables/hash_map_ds.py#L6-L10
Check out this resource handling hash table collisions