Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site gatech.UUCP Path: utzoo!watmath!clyde!burl!ulysses!gatech!jeff From: jeff@gatech.UUCP (Jeff Lee) Newsgroups: net.lang,net.lang.pascal Subject: Re: Hashing is not O(1), period. Message-ID: <11972@gatech.UUCP> Date: Mon, 11-Feb-85 11:46:12 EST Article-I.D.: gatech.11972 Posted: Mon Feb 11 11:46:12 1985 Date-Received: Tue, 12-Feb-85 06:23:23 EST References: <507@decwrl.UUCP> Organization: School of ICS, Georgia Institute of Technology, Atlanta Lines: 38 Xref: watmath net.lang:1417 net.lang.pascal:234 >- Hashing IS NOT an O(1) operation! >- >- Hashing is an O(N)/buckets operation, where many times you can use enough >- buckets to make it very fast. > . > . > . > Look at pages 104-108 of Knuth, The Art of Computer Programming, Vol. 1. > Section 1.2.11 is titled "Asymptotic Representation." You cannot place a > restriction on the size of a problem and then use big-O notation. O notation > specifically addresses unbound functions, and how the function (or algorithm) > behaves dependent upon problem size (for example, number of records in the > dictionary being searched). > > The fact (alluded to in my original message, but evidently not made clear > enough) that in many practical cases hashing can be used to give a bounded > (and possibly constant) lookup time for a bounded dictionary has nothing to > do with being O(1). > I was originally disagreeing with your statement that hashing is O(N)/(table size). That's why I looked up several of the more popular collision handling methods. I agree that looking up an item in a table is not O(1), but hashing CAN be O(1). Hashing is computing, by some arithmetic function, the "home" address of (normally) an identifier. There is no reason that this function cannot be O(1). When it comes time to insert it into the table, things begin to change but that doesn't mean that the hashing is not O(1). They make real good tables, though. A bound of 4-5 probes with a good hash algorithm and a fixed size, chained overflow collision handling is a lot better than a binary (figuring 5 probes on a tree would mean only 31 items in the tree). -- Jeff Lee CSNet: Jeff @ GATech ARPA: Jeff.GATech @ CSNet-Relay uucp: ...!{akgua,allegra,rlgvax,sb1,unmvax,ulysses,ut-sally}!gatech!jeff