Results 1 to 4 of 4
Thread: [SOLVED] HashTables
- 06-21-2009, 08:58 PM #1
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?
- 06-22-2009, 08:05 AM #2Member
- Join Date
- Feb 2009
- Rep Power
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 :)
- 06-22-2009, 10:01 AM #3
How do you read the values from the overflow area?
- 06-22-2009, 03:15 PM #4
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
- By arnab321 in forum New To JavaReplies: 2Last Post: 12-07-2008, 07:13 PM
- By SimC in forum New To JavaReplies: 19Last Post: 12-05-2008, 05:49 PM
- By ShoeNinja in forum New To JavaReplies: 0Last Post: 12-04-2007, 11:43 PM