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

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

1 Expert Approved Answer
Step: 1 Unlock

Lets calculate the integer value that the string CAY hashes to using the prov... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!