On Jan 7, 10:10 am, Vijay <[email protected]> wrote:
> Thanks for response.
>
> Can you please tell me what will be the contains of Hash table and how
> searching works?
>
> Lets say, we have one data like
> Key       Data
> ===========
> IP1 -  Sys1
> IP8    Sys8
> IP2    Sys2
>
> Lets say, there are keys  "IP1" and "IP8". and Hash_function will
> return 1 as index for both so collision occurred. And Hash_insert
> will
> insert "Sys2" at index 3 as 2 is already filled.
>
> I understand, Hash Table will have index (got from Hash_function) and
> corresponding data
>
> HashTable[index][data] ->
> [1]["Sys1"]
> [2]["Sys8"]
> [3]["Sys2"]
>
> Lets say we have searching/lookup function data_type GetData(key)
> which will take key and return correct data from table HashTable[index]
> [data]. Searching/lookup function will find index from key using
> Hash_function. And Hash_function will return duplicate index. then how
> it will locate correct data?
>
> Please let me know where am i wrong.

Simple. You have to store the key as well as the data.
The hashing is to limit the amount of entries you have
to look at to find the key-value *pair*.

--
Geoff
-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.


Reply via email to