My hash table is in need of peer review

M

micans

CBFalconer said:
I never saw any other part of this thread, but your comments only
make sense for a highly restricted set of hash table
implementations, i.e. those that handle overflow by linked lists
(or such) and where a (possibly long) string comparison can be
replaced by an integer comparison. Even then, string comparisons
normally find a difference in the first few characters, even if the
potential strings are long.

On the other hand re-organizing tables, that control the load
factor and thus the length of any chains involved, do not have this
problem. My hashlib keeps the load under about 88%, and the actual
load is more likely to be about 66%, resulting in very short chains
and expected O(1) performance.

My other response could have used more careful wording. It uses
(perhaps ill-chosen) 'rehashing' to refer to something that could be
similar to your 're-organizing'. In the quoted text above I write 'The
hashes adapt while growing; they double in size when the load factor is
exceeded'. This is a sloppy description of the way 'rehashing' works,
namely by doubling the number of buckets and recomputing the linked
lists. So I am curious about your 'On the other hand'. What are you
exactly contrasting it with?

Stijn
 
C

CBFalconer

.... snip ...

My other response could have used more careful wording. It uses
(perhaps ill-chosen) 'rehashing' to refer to something that could be
similar to your 're-organizing'. In the quoted text above I write 'The
hashes adapt while growing; they double in size when the load factor is
exceeded'. This is a sloppy description of the way 'rehashing' works,
namely by doubling the number of buckets and recomputing the linked
lists. So I am curious about your 'On the other hand'. What are you
exactly contrasting it with?

Some hash systems use a fixed size table and whenever a collision
occurs create a linked list originating at that bucket. This
system eventually degenerates into O(n).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,244
Members
46,838
Latest member
KandiceChi

Latest Threads

Top