• C

hash table with char* as keys

How do you build a hash table that uses char* as keys?
Who is Participating?
yairyConnect With a Mentor Commented:
Well, You mean using Strings as keys.
one good way is the assign the string
with in integer value that will
represent the cell in the array.

lets for example build an integer
from the word "Hello" by adding up
every letter Ascii value.

for (int i=0; i<strlen(str) i++)
  key=(key+str[i]) % 10000;

we just add the ascii value,
but will keep to be in range of
the hash table (10000, in this example)

because one would like to have
the key spred equaly as possible,
Adding might give advantage to Short string.

therethore, one can do a Multiply operation or even combline adding and multipy..

Any quetions...


Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.