I am having some trouble understanding the specifics of the universal hash
function talked about in the hash lecture.  I am interested in using
something like this on hw 4.5, but I don't understand how the variables a
and b were chosen.  Their values seem somewhat arbitrary.  How were these
values determined?

int hashU(String s, int M){
 int hash = 0, a = 31415, b = 27183;
 for(int i = 0; i < s.length(); i++, a = a*b % (M-1))
 hash = (a * hash + (int)s.charAt(i)) % M;

 return hash;
}

                        - Adam Scotto


Reply via email to