Question: In a hash table array of size 5, where the hash function is f(n)=n%5, if the hash table array is used to store integer


In a hash table array of size 5, where the hash function is f(n)=n%5, if the hash table array is used to store integer keys, will key 3 and key 8 to be put into the same slot in the array? If yes, then how to solve this situation? 2. (2pts) Suppose we have a hash table array of size 7, where the hash function is f(n) = n%7, and if the hash table array is used to store integer keys and uses linear probing to solve conflict. Which of the following diagrams shows the state of the hash table array after the following keys have been inserted: 3, 10, 18, 17, 4, 2 A I 3 17 2 4 4 10 18 1 10 10 18 17 15 10 1 47 4 2 3. (2pts) How do you use Java HashMap class to define an object that maps integers to strings? Please list the entire declaration statement. 4. (2pts) Suppose we have a Java HashMap object x that maps integers to strings. How do you add a hash map item (integer value 212, string value "Data Structure") to the object x? Please list the entire statement. 5. (2pts) Which method of Java HashMap will you use to replace a value of an existing key? 6. (2pts) Which method of Java HashMap will you use to remove a pair of hash map item (key/value pair)? 7. (2pts) Follow-up question, before you remove a pair of item, do you need to make sure the item exists in the hash map? What method you can use to make sure it exists?
Step by Step Solution
3.48 Rating (151 Votes )
There are 3 Steps involved in it
1 In Java HashMap if two keys have the same hash code they will be stored in the same slot in the un... View full answer
Get step-by-step solutions from verified subject matter experts
