Why we don't use Cuckoo Hashing











up vote
0
down vote

favorite












My question is from what i understand Cuckoo Hashing takes usually 0(1) time for insert delete and find. The worst case scenario is O(1) (amortized). My question is why isn't this algorithm used more often. Why would we use a different algorithm to look things up inserting or deleting rather then something like Cuckoo Hashing?










share|improve this question
























  • Possible duplicate of Advantages of Binary Search Trees over Hash Tables
    – James K Polk
    Nov 8 at 0:29










  • Are you asking why tree maps are more common than hash maps? If so, I'd say that's a false premise - hash maps are easily more commonly used in most languages / library ecosystems. Or are you asking why other resolution strategies are more common for hash maps than Cuckoo Hashing? If so, the "Practice" section of the Wikipedia article on Cuckoo Hashing might give one reason.
    – sepp2k
    Nov 8 at 0:32















up vote
0
down vote

favorite












My question is from what i understand Cuckoo Hashing takes usually 0(1) time for insert delete and find. The worst case scenario is O(1) (amortized). My question is why isn't this algorithm used more often. Why would we use a different algorithm to look things up inserting or deleting rather then something like Cuckoo Hashing?










share|improve this question
























  • Possible duplicate of Advantages of Binary Search Trees over Hash Tables
    – James K Polk
    Nov 8 at 0:29










  • Are you asking why tree maps are more common than hash maps? If so, I'd say that's a false premise - hash maps are easily more commonly used in most languages / library ecosystems. Or are you asking why other resolution strategies are more common for hash maps than Cuckoo Hashing? If so, the "Practice" section of the Wikipedia article on Cuckoo Hashing might give one reason.
    – sepp2k
    Nov 8 at 0:32













up vote
0
down vote

favorite









up vote
0
down vote

favorite











My question is from what i understand Cuckoo Hashing takes usually 0(1) time for insert delete and find. The worst case scenario is O(1) (amortized). My question is why isn't this algorithm used more often. Why would we use a different algorithm to look things up inserting or deleting rather then something like Cuckoo Hashing?










share|improve this question















My question is from what i understand Cuckoo Hashing takes usually 0(1) time for insert delete and find. The worst case scenario is O(1) (amortized). My question is why isn't this algorithm used more often. Why would we use a different algorithm to look things up inserting or deleting rather then something like Cuckoo Hashing?







algorithm hash






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 8 at 0:33

























asked Nov 8 at 0:23









shiv shah

133




133












  • Possible duplicate of Advantages of Binary Search Trees over Hash Tables
    – James K Polk
    Nov 8 at 0:29










  • Are you asking why tree maps are more common than hash maps? If so, I'd say that's a false premise - hash maps are easily more commonly used in most languages / library ecosystems. Or are you asking why other resolution strategies are more common for hash maps than Cuckoo Hashing? If so, the "Practice" section of the Wikipedia article on Cuckoo Hashing might give one reason.
    – sepp2k
    Nov 8 at 0:32


















  • Possible duplicate of Advantages of Binary Search Trees over Hash Tables
    – James K Polk
    Nov 8 at 0:29










  • Are you asking why tree maps are more common than hash maps? If so, I'd say that's a false premise - hash maps are easily more commonly used in most languages / library ecosystems. Or are you asking why other resolution strategies are more common for hash maps than Cuckoo Hashing? If so, the "Practice" section of the Wikipedia article on Cuckoo Hashing might give one reason.
    – sepp2k
    Nov 8 at 0:32
















Possible duplicate of Advantages of Binary Search Trees over Hash Tables
– James K Polk
Nov 8 at 0:29




Possible duplicate of Advantages of Binary Search Trees over Hash Tables
– James K Polk
Nov 8 at 0:29












Are you asking why tree maps are more common than hash maps? If so, I'd say that's a false premise - hash maps are easily more commonly used in most languages / library ecosystems. Or are you asking why other resolution strategies are more common for hash maps than Cuckoo Hashing? If so, the "Practice" section of the Wikipedia article on Cuckoo Hashing might give one reason.
– sepp2k
Nov 8 at 0:32




Are you asking why tree maps are more common than hash maps? If so, I'd say that's a false premise - hash maps are easily more commonly used in most languages / library ecosystems. Or are you asking why other resolution strategies are more common for hash maps than Cuckoo Hashing? If so, the "Practice" section of the Wikipedia article on Cuckoo Hashing might give one reason.
– sepp2k
Nov 8 at 0:32












1 Answer
1






active

oldest

votes

















up vote
1
down vote













Cuckoo hashing requires an unbounded number of different independent hash functions, which is not compatible with the way we usually implement a generic hash table, since that only requires one hash function to be specified.



If you are writing a hash table implementation for a specific data type, then the hash function(s) can be built into the table implementation and cuckoo hashing may be reasonable.



Even in that case, however, you probably won't be able to prove that you can support any set of elements, since your hash functions won't really be random and independent, so a cuckoo hashing implementation has O(1) expected time for insert, but in a real implementation there may be a case or two in which it will go into an infinite loop or fail.



You could engineer a fallback for cases like that, but then is cuckoo hashing worth the extra complexity?



Cuckoo hashing may be a good alternative to perfect hashing, when the hash table is computed in advance... but if you're doing it in advance then insertions don't usually have to be that fast so you can use perfect hashing instead.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53199889%2fwhy-we-dont-use-cuckoo-hashing%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    Cuckoo hashing requires an unbounded number of different independent hash functions, which is not compatible with the way we usually implement a generic hash table, since that only requires one hash function to be specified.



    If you are writing a hash table implementation for a specific data type, then the hash function(s) can be built into the table implementation and cuckoo hashing may be reasonable.



    Even in that case, however, you probably won't be able to prove that you can support any set of elements, since your hash functions won't really be random and independent, so a cuckoo hashing implementation has O(1) expected time for insert, but in a real implementation there may be a case or two in which it will go into an infinite loop or fail.



    You could engineer a fallback for cases like that, but then is cuckoo hashing worth the extra complexity?



    Cuckoo hashing may be a good alternative to perfect hashing, when the hash table is computed in advance... but if you're doing it in advance then insertions don't usually have to be that fast so you can use perfect hashing instead.






    share|improve this answer

























      up vote
      1
      down vote













      Cuckoo hashing requires an unbounded number of different independent hash functions, which is not compatible with the way we usually implement a generic hash table, since that only requires one hash function to be specified.



      If you are writing a hash table implementation for a specific data type, then the hash function(s) can be built into the table implementation and cuckoo hashing may be reasonable.



      Even in that case, however, you probably won't be able to prove that you can support any set of elements, since your hash functions won't really be random and independent, so a cuckoo hashing implementation has O(1) expected time for insert, but in a real implementation there may be a case or two in which it will go into an infinite loop or fail.



      You could engineer a fallback for cases like that, but then is cuckoo hashing worth the extra complexity?



      Cuckoo hashing may be a good alternative to perfect hashing, when the hash table is computed in advance... but if you're doing it in advance then insertions don't usually have to be that fast so you can use perfect hashing instead.






      share|improve this answer























        up vote
        1
        down vote










        up vote
        1
        down vote









        Cuckoo hashing requires an unbounded number of different independent hash functions, which is not compatible with the way we usually implement a generic hash table, since that only requires one hash function to be specified.



        If you are writing a hash table implementation for a specific data type, then the hash function(s) can be built into the table implementation and cuckoo hashing may be reasonable.



        Even in that case, however, you probably won't be able to prove that you can support any set of elements, since your hash functions won't really be random and independent, so a cuckoo hashing implementation has O(1) expected time for insert, but in a real implementation there may be a case or two in which it will go into an infinite loop or fail.



        You could engineer a fallback for cases like that, but then is cuckoo hashing worth the extra complexity?



        Cuckoo hashing may be a good alternative to perfect hashing, when the hash table is computed in advance... but if you're doing it in advance then insertions don't usually have to be that fast so you can use perfect hashing instead.






        share|improve this answer












        Cuckoo hashing requires an unbounded number of different independent hash functions, which is not compatible with the way we usually implement a generic hash table, since that only requires one hash function to be specified.



        If you are writing a hash table implementation for a specific data type, then the hash function(s) can be built into the table implementation and cuckoo hashing may be reasonable.



        Even in that case, however, you probably won't be able to prove that you can support any set of elements, since your hash functions won't really be random and independent, so a cuckoo hashing implementation has O(1) expected time for insert, but in a real implementation there may be a case or two in which it will go into an infinite loop or fail.



        You could engineer a fallback for cases like that, but then is cuckoo hashing worth the extra complexity?



        Cuckoo hashing may be a good alternative to perfect hashing, when the hash table is computed in advance... but if you're doing it in advance then insertions don't usually have to be that fast so you can use perfect hashing instead.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 8 at 1:48









        Matt Timmermans

        18k11532




        18k11532






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53199889%2fwhy-we-dont-use-cuckoo-hashing%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            Tangent Lines Diagram Along Smooth Curve

            Yusuf al-Mu'taman ibn Hud

            Zucchini