Author Topic: hashing  (Read 3561 times)

ygfperson

  • Founders
  • Posts: 601
  • Karma: +10/-1
    • Last.fm
hashing
« on: July 06, 2005, 12:56:48 AM »
Just wondering... do the majority of database/search programs which hash search strings have some kind of method that checks to make sure that a previous entry didn't have the same hash value? or do they just think that the chances are astronomical enough for the risk of a collision to outweigh the extra cost of checking every entry?

Major_Small

  • Jackass IV
  • Posts: 317
  • Karma: +10/-0
    • http://www.johnshaoonline.com
hashing
« Reply #1 on: July 06, 2005, 01:08:05 AM »
well with some forms of hashing (or should I say a good algorithm) that's not really possible... for example, seperate chaining. (near the bottom)
Team Cprog Folding@Home: Team #43476
Download it Here
Detailed Stats Here
More Detailed Stats
51 Members so far, are YOU a member?
Current team score: 827850 (ranked 357 of 41389)

The CBoard team is doing better than [COLOR='#0000FF']99.13%[/COLOR] of the other teams
Top 5 Members: Xterria(331048), Bennet(64957), pianorain(56621), Codeplug(35842), JaWiB(34917)

Last Updated on: Mon, 28 Nov, 2005 @ 3:21 PM EST

Perspective

  • badfish
  • Jackass In Charge
  • Posts: 4635
  • Karma: +64/-22
    • http://jeff.bagu.org
hashing
« Reply #2 on: July 07, 2005, 12:27:33 PM »
They just hash every entry to its position, if there is a collision they iterate by an offset AFAIK.

Major_Small

  • Jackass IV
  • Posts: 317
  • Karma: +10/-0
    • http://www.johnshaoonline.com
hashing
« Reply #3 on: July 07, 2005, 05:36:14 PM »
how could they possibly know where to look that up then? for example, if ABC hashes to position 3 and ABCD to position 4, how do they know where to find DEF (that was supposed to hash to 3, but is now in 5)?

that very quickly turns into a linear search...
Team Cprog Folding@Home: Team #43476
Download it Here
Detailed Stats Here
More Detailed Stats
51 Members so far, are YOU a member?
Current team score: 827850 (ranked 357 of 41389)

The CBoard team is doing better than [COLOR='#0000FF']99.13%[/COLOR] of the other teams
Top 5 Members: Xterria(331048), Bennet(64957), pianorain(56621), Codeplug(35842), JaWiB(34917)

Last Updated on: Mon, 28 Nov, 2005 @ 3:21 PM EST

Perspective

  • badfish
  • Jackass In Charge
  • Posts: 4635
  • Karma: +64/-22
    • http://jeff.bagu.org
hashing
« Reply #4 on: July 07, 2005, 06:09:37 PM »
>>that very quickly turns into a linear search...

indeed. and thats what happens if your hash structure is more than %75 full. A good hash function along with a %75 capacity is what makes an optimal hash structure. But this is just the basics of hashing, im sure apps like Berkely DB have more sophisticated approaches to optimize things.