MHB How to Insert Keys in a Hashtable Using Different Collision Resolution Methods?

  • Thread starter Thread starter evinda
  • Start date Start date
AI Thread Summary
The discussion revolves around inserting three keys (22, 15, 8) into a hashtable with 7 positions using two different collision resolution methods: coalesced chaining and open addressing. For coalesced chaining, participants confirm that the insertion process is correct. In the case of open addressing, the primary hash function places the first key (22) in slot 1, leading to a debate about whether the subsequent keys are placed correctly. One participant suggests that 22 should occupy slot 1, while another confirms their understanding and expresses gratitude for the clarification. The conversation highlights the importance of correctly applying hash functions and collision resolution strategies in hashtable implementations.
evinda
Gold Member
MHB
Messages
3,741
Reaction score
0
Hello! (Smile)

There are given three elements with keys $22, 15, 8$. Insert them in the given order in a hashtable of $7$ positions given that as method of treatement of the collisions we use:

  • hashing that follows the method coalesced chaining with the hash fuction $h(k)=k \mod m$
  • ordered hashing with open addressing strategies with the primary hash function $h_1(x)=x \mod m$ and the secondary hash function $h_2(x)=(x^2+1) \mod{7}$

That's what I have tried:

For the first case:

View attachment 3894

For the second case:

View attachment 3895Could you tell me if it is right? (Thinking)
 

Attachments

  • hash1.png
    hash1.png
    1.2 KB · Views: 109
  • hash2.png
    hash2.png
    1.1 KB · Views: 109
Technology news on Phys.org
Hey! (Wasntme)

I believe the first case is right. (Nod)

In the second case, the first value of 22 would still be inserted in slot 1 (using the primary hash function), so I think 22 should be there instead of 8. (Shake)
 
Did you figure it out? (Wondering)
 
I like Serena said:
Did you figure it out? (Wondering)

Yes, I did.. Thanks for your answer! (Smile)
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...
Back
Top