hash - Probing every R'th location for hashing -
something curious lecture:
suppose want probe every rth location function x mod 10 , r = 2. hash 4, 14, 114, 1114, , 11114:
- 4 go in slot 4.
- 14 first try slot 4, seeing it's full, it'll go slot 6 (+r).
- 114 find slot 4 full, going slot 6 (+r), since that's full, it'll go slot 0 (+2r).
but 1114, seems keep going on forever- no matter goes, it'll run full slot. happens in case?
there 3 alternatives unsolvable hash collisions on open addressing hash tables:
- re-hash entire table different hash function, , hope no new unsolvable hash collisions occur.
- resize table (with operations might incur), guarantee more possible slots.
- keep separate list unsolvable hash collisions.
none of options good.
what should chose probing method in combination hash table size. if table size odd, same constant step, not run in problem while there still space in table.
popular combinations include quadratic probing prime-sized hash table, guarantees insertion success if table less half-full, , quadratic probing triangular numbers , power of 2 hash table, guarantees insertion if table isn't full. power of 2 sized hash tables have many advantages, defect being unforgiving on quality of hash algorithm.
Comments
Post a Comment