Community discussion forum

Help:hash table

  • 2 months 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. 

  • Advertisement

    Simply the fastest line-level profiler for .NET ever

    “The low overhead means it has minimal impact on the execution of my program”
    Mark Everest, Development Team Leader, Renault F1 Team Ltd.

    Try out the new ANTS Profiler 4 for yourself. Download your 14-day trial now

  • 2 months 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).