Results 1 to 4 of 4
  1. #1
    jon80's Avatar
    jon80 is offline Senior Member
    Join Date
    Feb 2008
    Location
    Malta (EU)
    Posts
    211
    Rep Power
    7

    Default [SOLVED] HashTables

    How would you normally go about programming for hash collisions, and, ensuring the values with the same hash values can be read again, assuming that you want to retain values which generate the same hash key?

    Is it common to simply discard values which generate values which generate the same hash keys?

    What is a concrete example of data structures where a hashtable is an appropriate data structure?

  2. #2
    JohnnyR is offline Member
    Join Date
    Feb 2009
    Posts
    46
    Rep Power
    0

    Default

    The way they are handled are they are put into a 'overflow' area, if the value you are looking for is different from the one stored (first in best served) then it goes through the overflow area sequentially (very time consuming if you have LOTS of collisions) until it finds.

    Hope this helps :)

  3. #3
    jon80's Avatar
    jon80 is offline Senior Member
    Join Date
    Feb 2008
    Location
    Malta (EU)
    Posts
    211
    Rep Power
    7

    Default

    How do you read the values from the overflow area?

  4. #4
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    You follow some rule like "add 5 to index if a collision" and keep going until you find what you're looking for (by testing keys for equality). The number you add should be coprime to the number of elements in your table.

    Other methods include using the hash code to index an array of linked lists, or determine the path to take down a trie.
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

Similar Threads

  1. Replies: 2
    Last Post: 12-07-2008, 06:13 PM
  2. accessing hashtables from another class
    By SimC in forum New To Java
    Replies: 19
    Last Post: 12-05-2008, 04:49 PM
  3. Generic Hashtables
    By ShoeNinja in forum New To Java
    Replies: 0
    Last Post: 12-04-2007, 10:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •