Task 2. Instead of using the default hashCode method to each key, create a hash function applying the folding method. Within your hash function Split the string into 3 sub-strings, based from the reg-ex "-" Parse your sub-strings to Integer and add (folding method) Parse the summed value to String Initialize an int variable for your hash to 0 Loop to each character index of the String Apply the general formula for hashing: hash=31*hash+character in that index position; Append & exFFFFFFF to it to make the resulting hash positive Convert the hash to index of tablesize=20 using the % operator Return hash What index has the most occurrence of collisions?
Task 2. Instead of using the default hashCode method to each key, create a hash function applying the folding method.
Within your hash function
Split the string into 3 sub-strings, based from the reg-ex "-"
Parse your sub-strings to Integer and add (folding method)
Parse the summed value to String
Initialize an int variable for your hash to 0
Loop to each character index of the String
Apply the general formula for hashing: hash=31*hash+character in that index position;
Append & 0xFFFFFFF to it to make the resulting hash positive
Convert the hash to index of tablesize=20 using the % operator
Return hash
What index has the most occurrence of collisions?
![Task 2. Instead of using the default hashCode method to each key, create a hash function applying the folding method.
Within your hash function
Split the string into 3 sub-strings, based from the reg-ex "-"
Parse your sub-strings to Integer and add (folding method)
Parse the summed value to String
Initialize an int variable for your hash to 0
Loop to each character index of the String
Apply the general formula for hashing: hash=31*hash+character in that index position;
Append & exFFFFFFF to it to make the resulting hash positive
Convert the hash to index of tablesize=20 using the % operator
Return hash
What index has the most occurrence of collisions?](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F09030b0b-c4ac-463b-9b94-8c96438c96df%2Fe2892e59-bbcf-46b8-88bb-3951029ebf7d%2Fhpw2e3k_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 3 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)