C++/c++ searching
Expert: Eddie - 9/5/2005
Question-------------------------
Followup To
Question -
hey, how r u?
I am a beginner to c++ and have a question about hash searching in C++ that i was hoping you'd be able to assist me with.
I am using Microsoft visual studio, and am attempting to do the following:
1. create a hash key using modulo-division method
2. provide a function that will handle collisions (ie. i think linear probing?)
Any assistance is greatly appreciated.
Regards,
Flora
Answer -
Hello Flora, thank you for the question.
Creating a hash key with the modulous operator is fairly easy. But, just to ensure I understand you comepletely, do you think you could please explain to me what you mean by linear probing as a collision algorithm? That's a new one to me.
Thanks,
- Eddie
------------------
hi, thank you for your quick reply. I can see how my question was a bit confusing. I was referring to the open addressing mthod, and in particular to the linear probe where if a collision occurs, its resolved by adding 1 to the current address until an empty position is found.
I have already qritten up both the hash and collision functions, i'm just unsure of how to use them in my program. Ie. how do i say that "if a collision has occurred, implement collision function" (i am hashing an array of integers). I hope this clarifies things.
If not, that's ok.
Thanks very much.
Regards,
Flora
AnswerHello Flora, thanks again for the question.
Sorry about taking 2 days to reply, I stay extremely busy with work and graduate school.
I noticed that your original question was
1. create a hash key using modulo-division method
2. provide a function that will handle collisions (ie. i think linear probing?),
Now you state that "I have already qritten up both the hash and collision functions". Is your question that you don't know how to actually determine if a collision has occured? I'm still unsure of this linear probing algorithm of which you speak. If you could perhaps post some code it would be extremely appreciated.
Sorry this is being such a hassle.
- Eddie