/** * Code for exercise 3.2 * Lecture Series Informatik II D-BAUG ETH Zürich * Felix Friedrich, David Sidler */ class HashFunction{ static final int m = 101; // Modulo number static final int b = 31; //Prime number // pre: non-empty string s // post: returns value representing the string s public static int ComputeHash(String s) { int sum = 0; int B = b; for (int k = 0; k " + value); } input.close(); } } /* inputs that can be used to check correctness, for b=31 and m=101: If the inpout is '0' the program is gonna terminate. Inputs | Output -------------------------------- ABC | ABC => 28 abc | abc => 31 ETH | ETH => 58 900 | 900 => 31 xyz | xyz => 30 0 | exit. */