Covering All Our Bases
The solution to this problem is to use a different number base to represent our numbers. While our day-to-day number system uses base 10, if we want our hash function to cover 26 letters, we need to switch to base 26. This will ensure that each character’s hash code will be contained within one digit place.
If the previous paragraph made perfect sense to you, you can skip the rest of this section. But if you’re a little fuzzy on the details of number base systems, read on.
Take the number “ten.” Note how I spelled out this number using alphabetical characters. If I wanted to express this same number using numerical digits, I’d write “10.” However, this isn’t the only way to express the number “ten” using numerical digits. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access