*My interpretation of the questions is that if number of strings are
provided, you need to hash them to an array. So, in that case you can
maintain an array of char pointers..and use some hash function such as some
arithmetic on the ascii value of first character of the string...and the
array element would contain address of that string. Correct me, if I am
wrong. Thanks*

On Sun, Aug 14, 2011 at 11:15 PM, Dave <dave_and_da...@juno.com> wrote:

> @Rohit: Let T be an array of length 256 that contains a permutation of
> the numbers between 0 and 255. Then to hash string s[],
>
> h = 0;
> for( i = 0 ; s[i] ; ++i )
>    h = T[h^s[i]];  // or  h = T[h] ^ s[i];
>
> You can choose a random permutation for T, or, if you have a small
> known set of strings (e.g. C keywords), you can try to tailor T so
> that each given string has a unique hash value.
>
> Dave
>
> On Aug 14, 11:36 am, rohit <raman.u...@gmail.com> wrote:
> > I came accross a problem where i need to hash strings..
> > What is the best way to hash strings??
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
R@$!-!
"DoN'T LimIt Ur cHaLlEngeS, ChAlLenGe uR LImItS."

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

Reply via email to