Re: Hash specifics (Ron Guilmette)
13 Dec 90 06:40:27 GMT

          From comp.compilers

Related articles
Hash specifics (1990-12-11)
Re: Hash specifics (1990-12-11)
Re: Hash specifics chased@Eng.Sun.COM (1990-12-11)
Re: Hash specifics (1990-12-11)
Re: Hash specifics (1990-12-12)
Re: Hash specifics baxter@zola.ICS.UCI.EDU (Ira Baxter) (1990-12-13)
Re: Hash specifics lupine!rfg@uunet.UU.NET (1990-12-13)
Re: Hash specifics (1990-12-13)
Re: Hash specifics (1990-12-13)
Re: Hash specifics (1990-12-13)
Re: Hash specifics (1990-12-14)
Re: Hash specifics (1990-12-14)
Re: Hash specifics plx!plxsun!evan@Sun.COM (1990-12-15)
Re: Hash specifics (1990-12-16)
[4 later articles]
| List of all articles for this month |

Newsgroups: comp.compilers
From: (Ron Guilmette)
Keywords: design
Organization: Network Computing Devices, Inc., Mt. View, CA
References: <> <>
Date: 13 Dec 90 06:40:27 GMT

In article <> (Henry Spencer) writes:
>Actually, I have never figured out why people seem so obsessed with perfect
>hashing, since the hash functions typically seem noticeably expensive, and
>it has always seemed to me that a fast hashing function plus fast resolution
>of occasional collisions would be easier and just as good.

Henry's point is well taken, however there are *some* places where I think
that it is probably worth the effort to try to find a *perfect* hash
function. Keyword tables in compilers and opcode tables in assemblers
come to mind.

So perfect hash functions may be useful somtimes.

Note however that *minimal* perfect hash functions are not only never
absolutely *required*, but (as Doug Schmidt pointed out to me) they may
actually be *inefficient*!!!

The reason is that in a not-quite-minimal (but still perfect) hash
function, you will never have any "collisions" (so you don't have to waste
time on dealing with such cases) and also, if you happen to look up an
input key which does not even have a corresponding entry in your hash
table, then you will hash that input key into a hash key whose
corresponding primary table entry is empty! In such cases, you actually
SAVE TIME (relative to the case where you have a *minimal* perfect hash
function) because you won't even have to do a single comparison (of any
pair of complete keys).

[In a later message, Ron also points out:]

See also "The Art of Computer Programming" by Donald Knuth, book 3,
section 6.4.


// Ron Guilmette - C++ Entomologist
// Internet: uucp: ...uunet!lupine!rfg

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.