Question: What integer value does the string CAY hash to when the following hash function is used? Provide your answer by showing all intermediate values
What integer value does the string "CAY" hash to when the following hash function is used? Provide your answer by showing all intermediate values of h that get printed out, starting at i=0. Assume the code compiles, and show intermediate values you use in your hand calculations. Do not just provide a number, but please show your work. h: Answer below: h: String st = "CAY"; for (h=0,i=0; i < st.length(); i++) { h = ( 31sh+ st.charAt(i)) % 101; System.out.println (h); h: }
Step by Step Solution
3.43 Rating (150 Votes )
There are 3 Steps involved in it
Lets calculate the integer value that the string CAY hashes to using the prov... View full answer
Get step-by-step solutions from verified subject matter experts
