Question
In C++



raw the hash table that results from separate chaining using the follo 15 4 22 7 18 21 8 35 11 28 and the following hash function h(key)-key % 7 with a hash table size of 7. [47.1 points
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Initially the hashtable will be empty.

4 CR

Given hash function is key % 7.

1. For key 15, 15%7 = 1. So, it will be inserted at 1.

15 4 CR

2. Next 4 is inserted at 4 (since 4%7 = 4)

15 4 4 CR

3. Next element is 22. Now 22%7 = 1. But index 1 is already occupied with 15. Now separate chaining occurs. A new list will be created at the index 1 where rest of the elements with same hash value can be placed.

15 4 4

4. Next element is 7. 7%7 = 0. Hence it will be placed at index 0.

15 4 4

5. Next element is 18. 18%7 = 4. Since 4 is already occupied with element 4. Chaining occurs.

15 4 4 18 CR

6. 21 will be placed at 0 (with chaining) since 21%7 = 0.

21 15 4 4 18 CR

7. 8 will be placed at index 1 (appended in the list) since 8%7 = 1.

8. 35 too will be placed at index 0 since 35%7 = 0.

21 35 15 4 4 18

9. Now 11 will be appended at index 4 since 11%7 = 4.

15 4 4 18

10. 28 will be appended at index 0 since 28%7 = 0. (This is the final hashtable state)

21 35 28 15 4 4 18 11

Add a comment
Know the answer?
Add Answer to:
In C++ raw the hash table that results from separate chaining using the follo 15 4...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Separate Chaining A hash table of size 7 uses separate chaining to resolve collisions. A polynomial...

    Separate Chaining A hash table of size 7 uses separate chaining to resolve collisions. A polynomial hash function where a 33 is used. Sketch the table's contents after the following words have been added in the exact order shown: find, edge, body, race, plan, beat, they You may find it useful to create a list of lowercase letters and their ASCII numeric value. The letter a's value is 97 and z's value is 122. Linear Probing: A hash table of...

  • 5. Hashing (a) Consider a hash table with separate chaining of size M = 5 and...

    5. Hashing (a) Consider a hash table with separate chaining of size M = 5 and the hash function h(x) = x mod 5. i. (1) Pick 8 random numbers in the range of 10 to 99 and write the numbers in the picked sequence. Marks will only be given for proper random numbers (e.g., 11, 12, 13, 14 ... or 10, 20, 30, 40, .. are not acceptable random sequences). ii. (2) Draw a sketch of the hash table...

  • Assume you are given a separate chaining hashtable where M=11. Give the final hashtable after adding...

    Assume you are given a separate chaining hashtable where M=11. Give the final hashtable after adding keys: 24, 1, 4, 11, 12, 22, 33, 45, 8, 19, and 10. Use the hash function hash(k) = k mod 11, where k is the key. Include the main size M array with lists located at each index. Only include the key, not the hashed value, in your final table. Your table should look similar to the one below. Index List 0 [Key1,...

  • secondary clustering in a hash table occurs when using a. separate chaining b. double hashing c....

    secondary clustering in a hash table occurs when using a. separate chaining b. double hashing c. linear probing d. quadratic probing

  • List the contents of a hash table of SIZE 10 filled using chaining Use the hash function: index= ...

    Java question need help For the data elements can be item1, item2, item3 ,item4.... etc. List the contents of a hash table of SIZE 10 filled using chaining Use the hash function: index= ((string. length() * 3) The data elements are: Add the elements in the order given List the elements contained in each "bucket" (if any) Elements should be chained in the order added, separated by a comma and a space If an index is empty enter the word...

  • 5. Draw the hash table that results using the hash function: h(k)=kmod13 to hash the keys...

    5. Draw the hash table that results using the hash function: h(k)=kmod13 to hash the keys 18, 41, 22, 44, 59, 32, 31, 73. Assuming collisions are handled by Double hashing. ['M' is '7' which is less than the HTS and the hash function does not evaluate to '0'].

  • 10. (5 points) Consider data with integer keys 28, 21, 11, 47, 36, 19, 32 in...

    10. (5 points) Consider data with integer keys 28, 21, 11, 47, 36, 19, 32 in that order inserted into a hash table of size 7 and hashing function is h(key) = k % 7. Show a chaining hash table after doing the insertions:

  • for java 4. Instead of using a linked list to resolve collisions, as in separate chaining, use a binary search tre...

    for java 4. Instead of using a linked list to resolve collisions, as in separate chaining, use a binary search tree. That is, create a hash table that is an array of trees. To display a small tree-based hash table, you could use an inorder traversal of each tree. The advantage of a tree over a linked list is that it can be searched in O(logN) instead of O(N) time. This time savings can be a significant advantage if very...

  • It should be really short and simple to do this. #1 [8 points) Sketch a hash...

    It should be really short and simple to do this. #1 [8 points) Sketch a hash table of size N=11, where the hash function is hash(key) = key mod N and chaining is used to resolve collisions, when the following elements are inserted: 20, 42, 45, 49, 62, 72,95 0 1 2 3 4 5 6 7 8 9 10 What is the size of the largest bucket? — #2 [7 points) Sketch a hash table of size N=11, where...

  • Assume data is to be stored in a hash table using the following keys: 62,77.26, 42,...

    Assume data is to be stored in a hash table using the following keys: 62,77.26, 42, 52,76 Assume the hash table size is 7, the hash function used is the modulo function i.e. h/key) = key % table_size, and collisions are handled using linear probing. What's the content of the table after all keys are mapped to the hash table? (List keys starting from table index 0 and on Separate numbers by a comma and a single space, and indicate...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT