Help:hash table

  • 10 years ago

    I am ashamed to say that, although I have studied Computer Science for a MSc degree, I have never been taught hash table!!  Can somebody tell me what it is!?  I do remember reading a book which mentions a hash table to locate something like finding a word in a dictionary.  Lately I have been applying for a job and a number companies ask me about hash or hash table!!  Can somebody tell me what it really is!!  If someone can tell me where I can get a good book about it, I will be grateful!

    Thanks

    Chong. 

  • 10 years ago

    Hi Chong! ;)

    => That's not a special thing itself! but usually algorithms to implement that, is somewhat complicated(but there is simple ones too, it depends on efficiency).

    But what's a hashtable? it's a table of hashes! in programming it's a data structure that you can save some key/value pairs in that,  then when you want a value, you just need to specify its key and you have the value, just like an array. But the main difference is the way it saves and returns a value, the special algorithm comes here, it will compute key of the value and returns that, then you can use the key later to retrieve the value. Also the structure is a little different from an array, but its implementation is easy(it may use pointers). The main characteristic of a hash table is 'returns value of a key very fast'. Actually, the special way of saving and returning values(the algorithm) is a mean to achieve that speed. You can find the algorithms and data structures for hash tables in Data Structures books(you can find infos in websites and also by downloading an eBook).

    Then, we should consider two main things to implement a hash table : 1.Structure 2.Algorithm

    In C++, you can use 'hash_map' that is an associative container from STL :

    #include <hash_map>

    The infos about that exist in MSDN.

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“There's no test like production” - Anon