Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

X 1 2 2 9 : Hash Function Sum Digits Write a function in Java called hashSumDigits ( ) that will take a non -

X1229: Hash Function Sum Digits
Write a function in Java called hashSumDigits() that will take a non-negative value to be stored in a hash table and the size of the table and returns the index where the value will be stored.
This hash function sums all the digits in the value to be stored and then returns the modulo of that sum with the size of the table.
You should use a loop to sum of all the digits. Remember that mod(%) by 10 yields the rightmost digit (e.g.,126%10 is 6), while division () by 10 removes the rightmost digit (e.g.,12610 is 12).
Examples:
hashSumDigits (126,5)4
hashSumDigits (49,5)3
hashSumDigits (731,5)1
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Accounting And Auditing Research And Databases Practitioner's Desk Reference

Authors: Thomas R. Weirich, Natalie Tatiana Churyk, Thomas C. Pearson

1st Edition

1118334426, 978-1118334423

More Books

Students also viewed these Databases questions