+ 3

What is the logic to implement open addressing(linear probing)??

I have implemented C program of perfect hashing. But when the collision occurs then how can I solve it using open addressing (linear probing). Only we need to make a changes in else part of insert() function. So I need logic of open addressing. To put in else part of insert(). https://code.sololearn.com/cYG5j5pG2dWM/?ref=app

8th Sep 2020, 10:15 AM
Sadaf Shaikh
Sadaf Shaikh - avatar
6 Answers
+ 3
Thank you so much all...but I solved my problem myself😊 Here is the solution. https://code.sololearn.com/cq1A73qh8VWU/?ref=app
8th Sep 2020, 11:41 AM
Sadaf Shaikh
Sadaf Shaikh - avatar
+ 3
Im using c not cpp
8th Sep 2020, 10:27 AM
Sadaf Shaikh
Sadaf Shaikh - avatar
+ 3
And the link of program that I have provided above is working perfectly. That is the program of perfect hashing. I need logic of linear probing.
8th Sep 2020, 10:29 AM
Sadaf Shaikh
Sadaf Shaikh - avatar
+ 3
Do you know the concept of linear probing or open addressing??
8th Sep 2020, 10:41 AM
Sadaf Shaikh
Sadaf Shaikh - avatar
+ 3
👍
8th Sep 2020, 2:37 PM
Sadaf Shaikh
Sadaf Shaikh - avatar
+ 2
I think you should add break statement after adding an element into. Linear probing is a technic of add element if the current (hash result) location is already occupied then just add element in linearly next free empty space. For ex : If location are 1 to 10, if you want add 3, but 3,4 is are occupied then add in next free space that is 5. But this technic may get difficulties in searching.. Hope it make sense and helps...
8th Sep 2020, 1:32 PM
Jayakrishna 🇼🇳