how to implement own hash table in c programming language?

plz help me !!!!!
1 Like

You can use two arrays. Store the key in one array, value in the other, at the same index.

For example,

               0     1    2     3     4 

Array 1      A    B    C    D    E

Array 2      65   66   67   68   69

Note: This is a very, very basic method of creating a hash-table. There can be cases where there are several keys, which result in ‘collisions’.

@trek if you want to implement hash function then its totally depends upon the type of key and also type of value with the dependency over their ranges.I think you should prefer that hashing function that have minim probability of collosion infact i recommend you to have a look over the STL container map and multimap.I think they suits your requirement.

my keys are integers and my values are strings…
then in c how?

You can check out my answer for a int->string mapping. Consider Array 1 to be a string array and Array 2 to be an integer array.

This is an extremely interesting task and it has to be one of the best things a programmer can do…

I have written a tutorial on how to do this:

You can download a pdf document which you can find there and I really hope this can help you!! On that document there is a very detailed explanation as well as an implementation :slight_smile:

Best regards,


nice one !!

1 Like

Glad you liked it :slight_smile: