Earlier quoted context omitted.
The linear time behavior of cuckoo hashing is not triggered only when the table has to be enlarged, like standard containers (say, std::vector or python list): a linear numbers of keys can be "cuckooed" out of their slots for an insertion even when the load factor is under the capacity threshold. In standard containers if you pre-define the capacity (say with std::vector::reserve) all the insertions are guaranteed to…
I'm unaware of any hash table implementations which successfully insert elements in absolute constant time in the event of collisions.
Hash tables with O(1) worst-case lookup and space efficiency [pdf]
21–30 of 45 posts
Re: Hash tables with O(1) worst-case lookup and space efficiency [pdf]
#22"WHY ELSE IS THIS COOL?" seems a very casual heading for an academic article.
Re: Hash tables with O(1) worst-case lookup and space efficiency [pdf]
#23Earlier quoted context omitted.
Chained hash tables have constant time insertion, but I'm not sure about the amortized lookup time (the worst case is linear)
Chaining requires a memory allocation and list insertion on collisions - is it fair to call that absolute constant time? Probability of this happening depends on the number of elements in the container.
List insertion is O(1) if you insert it at the head, and while moving the most-recently-accessed link to the head of the chain doesn't change the worst case behavior, it greatly improves the average in practice (and is dead easy).
Re: Hash tables with O(1) worst-case lookup and space efficiency [pdf]
#24I recently did an exercise on cuckoo hashing at http://programmingpraxis.com/2011/02/01/cuckoo-hashing/ .
Re: Hash tables with O(1) worst-case lookup and space efficiency [pdf]
#25Earlier quoted context omitted.
Chained hash tables have constant time insertion, but I'm not sure about the amortized lookup time (the worst case is linear)
Chaining requires a memory allocation and list insertion on collisions - is it fair to call that absolute constant time? Probability of this happening depends on the number of elements in the container.
About allocation, I agree with you that it is "slow", but all reasonable computation models count a memory allocation as a constant time operation. If we want to go down that road and measure also memory operations, even random memory access would not be worst-case constant time: the MMU has to map the page to the physical location, and this is usually a logarithmic or amortized constant time operation.
Re: Hash tables with O(1) worst-case lookup and space efficiency [pdf]
#26http://www.eecs.harvard.edu/~michaelm/postscripts/esa2009.pd...
Re: Hash tables with O(1) worst-case lookup and space efficiency [pdf]
#27Re: Hash tables with O(1) worst-case lookup and space efficiency [pdf]
#28The amazing part is, not only is access O(1), the expected insertion time whenever there is no rehashing is also O(1) and rehashing occurs infrequently.
Re: Hash tables with O(1) worst-case lookup and space efficiency [pdf]
#29Cuckoo hashing is not only optimal in theory, it is also very fast in practice. The only downside, though, is that the insert time has linear-time worst case. Thus it may be not the best solution if latency is an issue.
Re: Hash tables with O(1) worst-case lookup and space efficiency [pdf]
#30The ones that come with most languages or libraries by default quite simply aren't optimized for use on anything. There's hash functions that work better on strings and hash functions that work better on numbers (length bias). In the perfect world, this wouldn't be true, but in the real world, yes it is.
That said, may I recommend MurmurHash3: code.google.com/p/smhasher/wiki/MurmurHash3
Switch your hash tables to this. The performance difference is incredible.