Score:0

Modular hashing confusion

je flag

I am trying to learn about basic hashing using the modulo operator and am a bit confused. In the text that I am reading, it says that the modulo operator can be used to accept an input of any length and return a fixed-size output. However, take 1mod11 = 1 and 21mod11 = 10. The first equation yields a one-digit number and the second equation yields a two-digit number, how is it returning a fixed-sized output? Yes, a trivial question, but it's just not clicking for me - anyone care to explain?

Score:2
gb flag

Your example (using mod 11) is fixed-size in the number of digits because it will never be more than 2 digits. If you don't like having 1 or 2 digits, you can prefix the 1-digit number with leading 0s. If you took all the numbers mod 10, they'd all be 1 digit.

Other ways of thinking about it

The output can always be represented by $n$ or fewer digits.

The output is one of a finite set of values, e.g., 0, 1, 2, 3, ..., 10.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.