Archived

This topic is now archived and is closed to further replies.

what is a hash table?

This topic is 5119 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Can anyone explain what a hash table is, what it is used for, and how to use one? links are welcome. I couldn''t find any decent tutorial''s/explanations from (searching) google.com, and this site''s search engine is just giving me internal errors.

Share this post


Link to post
Share on other sites
In simply words a hash table is an array, where each index of the array, you would have a linkedlist containing some sort of data (for example student record).

Picture:
index 0: [[("john",98908,3.4,"M"), ("ron",94908,3.5,"M")]]
index 1: [[]]
index 3: [("Tina",98568,3.3,"F")]
.
.
.
and so on.

How does hash table works?
One way:
You would initialize an array of certain length first. Then there is something called hashing number generated by the hashing algorithm, which determines where the data will go in the hash table. For example , in the above example, the hashing number would be determine by the student''s ID. The hashing number will be always be 0 <= H(x) < length(hastable). SO for example the the hashing number to Id 98908 came out to be 0, therefore you insert john''s record in the linked list of the first position in your hash table.



Now, there different way of doing a hashing problem. There are different hashing techniques. Sorry, i am in a hurry right now so i would say before u read on technical details, first read on the theory of hashing. Where?
Where else, google of course

Share this post


Link to post
Share on other sites