Help using Horner's rule and Hash Functions in JAVA?

Posted by Matt on Stack Overflow See other posts from Stack Overflow or by Matt
Published on 2010-05-01T21:36:21Z Indexed on 2010/05/01 21:57 UTC
Read the original article Hit count: 339

Filed under:
|

I am trying to use Horner's rule to convert words to integers. I understand how it works and how if the word is long, it may cause an overflow. My ultimate goal is to use the converted integer in a hash function h(x)=x mod tableSize. My book suggests, because of the overflow, you could "apply the mod operator after computing each parenthesized expression in Horner's rule." I don't exactly understand what they mean by this. Say the expression looks like this:

((14*32+15)*32+20)*32+5

Do I take the mod tableSize after each parenthesized expression and add them together? What would it look like with this hash function and this example of Horner's rule?

© Stack Overflow or respective owner

Related posts about java

Related posts about hashtable