Why is this hash function for english words is perfect hash?

1.4k Views Asked by At

I have a question that seems really intuitive to me but I can't think of a way to prove it.

Assume we a have a file with words that are different from each other and contain digits only for example "1234", "456" etc.

So a simple perfect hash function is to calculate for "1234" :$ 4*10^0 + 3*10^1 + 2*10^2 + 1*10^3 = 1234 $ and put in the hash table in this index,

and this promise us that every 2 words will be mapped to different cells.

Similarly, For words that contain only enligh letter "aba", "abc" someone told me that a perfect hash would be:$ 'a'*26^0 + 'b'*26^1 + 'a'*26^2 $ (26 becuase this is the number of english letters) but I can't prove why this is true, so my question is: why is this mapping promise us that every 2 different words will be mapped to different cells? how can I prove it?