Question

In: Computer Science

Use double hashing and the following hash functions: hash(key) = (key % table size) and hash2(key)...

Use double hashing and the following hash functions: hash(key) = (key % table size) and hash2(key) = (16 - (key % 10)) + 1 to insert the following numbers into a dictionary's hash table: 1, 12, 14, 3, 5 and 17. The table size is 11. Show the table and where each value is inserted. No coding required for this problem.

Solutions

Expert Solution

Inserting 1
main hash value is 1
1 is inserted at position 1
-, 1, -, -, -, -, -, -, -, -, -

Inserting 12
main hash value is 1
There is already an item in 1
double hash value is 16
1 + 1*16 = 17
So, checking at index 17 % 11 = 6
12 is inserted at position 6
-, 1, -, -, -, -, 12, -, -, -, -

Inserting 14
main hash value is 3
14 is inserted at position 3
-, 1, -, 14, -, -, 12, -, -, -, -

Inserting 3
main hash value is 3
There is already an item in 3
double hash value is 16
3 + 1*16 = 19
So, checking at index 19 % 11 = 8
3 is inserted at position 8
-, 1, -, 14, -, -, 12, -, 3, -, -

Inserting 5
main hash value is 5
5 is inserted at position 5
-, 1, -, 14, -, 5, 12, -, 3, -, -

Inserting 17
main hash value is 6
There is already an item in 6
double hash value is 16
6 + 1*16 = 22
So, checking at index 22 % 11 = 0
17 is inserted at position 0
17, 1, -, 14, -, 5, 12, -, 3, -, -

HashTable
-----------
0   -      17
1   -      1
2   -     
3   -      14
4   -     
5   -      5
6   -      12
7   -     
8   -      3
9   -     
10      -     

Related Solutions

Data Structures: Hashing Exercise: 1. a) Given an empty “separate chaining hash table” of size 10,...
Data Structures: Hashing Exercise: 1. a) Given an empty “separate chaining hash table” of size 10, with hash function                        Location = Number modulus 10 Show the hash table after inserting the following numbers: 21, 18, 27 , 31 , 48, 51 , 37, 98, 17 b) What table size would be better? 11? 12? 20? 2. We want to hash name strings into a chaining hash table of size 10, how would you divide the alphabet into 10 groups?...
3. Assume a hash table with 7 locations and the hashing function h(i) = i%7. Show...
3. Assume a hash table with 7 locations and the hashing function h(i) = i%7. Show the hash table that results when the integers are inserted in the order given. (10 points each. Total 30) • 5, 11, 18, 23, 28, 13, 25, with collisions resolved using linear probing • 5, 11, 18, 23, 28, 13, 25, with collisions resolved using quadratic probing • 5, 11, 18, 23, 28, 13, 25, with collisions resolved using chaining.
In C++ Use vectors instead of linked lists Create a Hash table program using H(key) =...
In C++ Use vectors instead of linked lists Create a Hash table program using H(key) = key%tablesize with Chaining and Linear probing for a text file that has a list of 50 numbers Ask the user to enter the file name, what the table size is, and which of the two options they want to use between chaining and linear probing
For the division method for creating hash functions, map a key k into one of m...
For the division method for creating hash functions, map a key k into one of m slots by taking the remainder of k divided by m. The hash function is:        h(k) = k mod m,     where m should not be a power of 2. For the Multiplication method for creating hash functions,     The hash function is h(k) = └ m(kA –└ k A ┘) ┘ = └ m(k A mod 1) ┘    where “k A...
SHOW WORK Draw the hash table that results using the hash function: h(k)=kmod7 to hash the...
SHOW WORK Draw the hash table that results using the hash function: h(k)=kmod7 to hash the keys 41, 16, 40, 47, 10, 55. Assuming collisions are handled by Double hashing. SHOW WORK
Implement one of the hashing procedures that we have discussed, and the following related functions: INSERT...
Implement one of the hashing procedures that we have discussed, and the following related functions: INSERT (item) DELETE (item) FIND (item) Make sure that your program correctly handles collisions and full hash table!
When using secure hash functions in an RSA signature, why do we sign the hash Sign...
When using secure hash functions in an RSA signature, why do we sign the hash Sign (H (m)) instead of taking the take the hash H (Sign (m)) ?
2. The success of a hash-table implementation of the ADT table is related to the choice...
2. The success of a hash-table implementation of the ADT table is related to the choice of a good hash function. A good hash function is one that is easy to compute and will evenly distribute the possible data. Comment on the appropriateness of the following hash functions. What patterns would hash to the same location. a. The hash table has size 2048. The search keys are English words. The hash function is h(key) = (sum of positions in alphabet...
Explain what the following notions mean for hash functions and compare their strength. Please don’t copy...
Explain what the following notions mean for hash functions and compare their strength. Please don’t copy the definitions from the class slides, explain them with your own words. • Collision Resistant • Pre-image Resistant • Second Pre-image Resistant
[Hash Tables] Given the following code in C++, implement the functions in table2.cpp. The first 2...
[Hash Tables] Given the following code in C++, implement the functions in table2.cpp. The first 2 files (table2.h, short story text file) are all fully coded and commented for convenience. *****I have given references that I've completed previously for the table2.cpp file, I just need help applying them. Will provide good rating, thanks****** -------------------------------------------------------------------------------------------------------------------------- table2.h (given file, do not edit): // FILE: table2.h // // ABSTRACT BASE CLASS: Table //    1. The number of records in the Table is...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT