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

  • Context: MHB 
  • Thread starter Thread starter evinda
  • Start date Start date
Click For Summary

Discussion Overview

The discussion revolves around inserting keys into a hashtable using different collision resolution methods. Participants explore the application of coalesced chaining and open addressing strategies, specifically focusing on the hash functions involved.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant presents a scenario with keys 22, 15, and 8, and describes the use of coalesced chaining with the hash function $h(k)=k \mod m$.
  • The same participant also discusses ordered hashing with open addressing, using primary and secondary hash functions $h_1(x)=x \mod m$ and $h_2(x)=(x^2+1) \mod{7}$.
  • Another participant agrees with the first case of coalesced chaining but challenges the placement of the first value (22) in the second case, suggesting it should occupy a different slot than proposed.

Areas of Agreement / Disagreement

There is partial agreement on the first case, while the second case remains contested with differing views on the correct placement of the keys.

Contextual Notes

Participants do not provide complete resolutions for the mathematical steps involved in the hashing process, leaving some assumptions and dependencies on definitions unresolved.

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: 130
  • hash2.png
    hash2.png
    1.1 KB · Views: 129
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)
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
17
Views
3K
  • · Replies 11 ·
Replies
11
Views
4K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
4K