Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Algorithms
  4. Hashtable with two tables (Cuckoo Hashing)

Hashtable with two tables (Cuckoo Hashing)

Scheduled Pinned Locked Moved Algorithms
algorithmsquestionlounge
4 Posts 4 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    Quake2Player
    wrote on last edited by
    #1

    Hello, I havent found much information about cuckoo hashing apart from the official papers.. I have some questions about it, 1. What would be two good random functions for this type of hashing? 2. What about the rehashing algorithm? Because i'm having troubles with the official specification of it.. which kinda loops between inserting and rehashing infinitely

    M N S 3 Replies Last reply
    0
    • Q Quake2Player

      Hello, I havent found much information about cuckoo hashing apart from the official papers.. I have some questions about it, 1. What would be two good random functions for this type of hashing? 2. What about the rehashing algorithm? Because i'm having troubles with the official specification of it.. which kinda loops between inserting and rehashing infinitely

      M Offline
      M Offline
      Moreno Airoldi
      wrote on last edited by
      #2

      I have no experience with cuckoo hashing, so I can't help you there. If you need to manage hash collisions and have problems with cuckoo or are worried about infinite loops and rehashing, you may consider using chaining[^]. While it's not as performing as cuckoo, it's very simple to implement, scalable, and works like a charm. :)

      2+2=5 for very large amounts of 2 (always loved that one hehe!)

      1 Reply Last reply
      0
      • Q Quake2Player

        Hello, I havent found much information about cuckoo hashing apart from the official papers.. I have some questions about it, 1. What would be two good random functions for this type of hashing? 2. What about the rehashing algorithm? Because i'm having troubles with the official specification of it.. which kinda loops between inserting and rehashing infinitely

        N Offline
        N Offline
        Nagy Vilmos
        wrote on last edited by
        #3

        How about using a modified Jenkins One a at a Time[^] Instead of starting the hash from zero, I tried getting the first hash using root 0 and the second using the first as a root. The two resulting hash's are pretty well distributed.


        Panic, Chaos, Destruction. My work here is done.

        1 Reply Last reply
        0
        • Q Quake2Player

          Hello, I havent found much information about cuckoo hashing apart from the official papers.. I have some questions about it, 1. What would be two good random functions for this type of hashing? 2. What about the rehashing algorithm? Because i'm having troubles with the official specification of it.. which kinda loops between inserting and rehashing infinitely

          S Offline
          S Offline
          supercat9
          wrote on last edited by
          #4

          I'd never heard of cuckoo hashing before; it seems like an interesting concept, though I would be paranoid about worst-case behavior if hash functions are poorly chosen (most hash table algorithms will run in bounded time even with the worst possible hash functions; the worst-case time to add an item to a cuckoo-hash table would seem to be unbounded). At the expense of some extra book-keeping (probably O(1) in typical cases, but bounded even in the worst case), I would think one could implement a variation of cuckoo hash in which every item was stored at location (H1+k*H2) mod N (as with double hashing), but which provided that if the cell targeted by an item with a certain 'k' contained an item with a sufficiently smaller 'k', the latter item would be displaced. That would tend to balance out the number of search steps required to find any particular item. Provided that H2 is always relatively prime to N, the algorithm should always terminate. If there are never any deletions, the extra book-keeping would be minimal; deletions could complicate things, though.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups