Question

In: Computer Science

Java Hash table, What does the separate chaining ST look like for M=3 and the following...

Java Hash table,

What does the separate chaining ST look like for M=3 and the following input key, hash pairs? A,0 F,0 Z,2

Solutions

Expert Solution

In hashing, we associate keys to indexes of our table. This helps in reducing the time complexity for common operations such as insertion, search, deletion to an average of O(1). We use a hash function to map keys to indexes. When two different keys map to the same index, it is known as a collision. Although number of collisions can be reduced, but collisions can never be eliminated completed if the number of entries in the table(N) is greater than the size of table(M). For efficient implementation of operations like  searching, we try reduce the number of collisions. However since collisions cannot be completely eliminated,  to deal with collisions we use various collision resolution techniques.

Separate chaining is a collision resolution technique in which we create separate chains for all entries that map to a particular index. These chains are created using linked lists, we create a separate linked list for each index of our hash table. So say if we two keys A and B map to index 0, then index 0 of out hash table will point to a linked list, which contains two nodes, one for A and one for B.

Now in the above question we have M = 3, two keys A and F map to 0th index and key Z maps to 2nd index. So out hash table will have a linked list  containing two nodes as it's index 0. No node at index 1 and a single node for Z at index 2. The final hash table along with the state of hash table after each insertion is shown by in below image.


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?...
what does a 6f orbital look like?
what does a 6f orbital look like?
what does the future of HIPAA look like
what does the future of HIPAA look like
What does the Future of TelaDoc look like?
What does the Future of TelaDoc look like?
3. Draw the hash table that results using the hash function: h(k)=kmod 7 to hash the...
3. Draw the hash table that results using the hash function: h(k)=kmod 7 to hash the keys 50, 700, 76, 85, 92, 73, 101. Assuming collisions are handled by Quadratic probing. Don't write a program. Just please manually solve the problem. Thanks.
What would the code look like if you weren't using hash maps and array lists (only...
What would the code look like if you weren't using hash maps and array lists (only using scanner import) and solving using a partition algorithm?
3. What would the titration curve look like if 0.10 M NaOH were in the flask...
3. What would the titration curve look like if 0.10 M NaOH were in the flask and 0.10 M HCl were in the buret? Make a rough sketch to illustrate your answer. 11. Biochemists and biologists often use the Henderson-Hasselbalch equation in working with buffers. When an acid solution is half-neutralized, half of the HA has been converted to A , and half of it is still in the form of HA. Therefore [HA] = [A ]. What happens to...
Implement a Cuckoo hash table in which two separate tables are maintained. Each table should have...
Implement a Cuckoo hash table in which two separate tables are maintained. Each table should have a fixed size of 13. Use the hash function h1(x) = x mod 13 for the first table, and h2(x)= 11 – (x mod 11) for the second table. Your program should read an input file, input.txt, consisting of one input per line, insert the input to the table in order, and print out the final content of the hash table in the provided...
What does an extraordinary nurse look like to you?
What does an extraordinary nurse look like to you?
A hash table works as follows. We allocate a table of m slots. All the items...
A hash table works as follows. We allocate a table of m slots. All the items we intend to store in the table belong to a large set U of items. We adopt a function f: U ->{0,1...m-1) which maps an item to a slot. Suppose we seek to store n items from U in a table of m slots. (a) Suppose f maps every item in U with equal probability to one of the m slots. What is the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT