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.

Thanks,

On Jan 7, 9:14 am, Geoffrey Summerhayes <[email protected]> wrote:
> On Jan 6, 2:54 pm, Vijay <[email protected]> wrote:
>
>
>
>
>
> > Hi All,
>
> > I have one question about Hashing.
>
> > Say I have one Hash table where
> > index Hash_function(key) function will return index value of
> > corresponding string/key.
> > Hash_insert(key) function it will take key and get converted index
> > value using Hash_function(key) and insert into two dimensional
>
> > Array[index][data] ->
> > [1]["Hello"]
> > [2]["ss"]
> > [3]["World"]
>
> > To deal with collision we will use Liner probing or a separate
> > function which will increment the index to next location in array if
> > collision occurred.
>
> > I understand, to lookup or search value/data we need to use
> > Hash_function again to get index and then search in array/table.
>
> > My question is -> in case of Liner probing, how we will retrieve the
> > data corresponding to key?
>
> > Lets say, there are keys  "Hello" and "World". and Hash_function will
> > return 1 as index for both so collision occurred. And Hash_insert will
> > insert "World" at index 3 as 2 is already filled.
>
> > Now how searching function will retrieve correct data?
>
> > Liner probing is described here 
> > ->http://www.cs.auckland.ac.nz/software/AlgAnim/hash_tables.html
> > Hope I am clear. Thanks in advance.
>
> Don't really see the problem. Just compare the keys.
>
> --
> 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