expected number of probes for a search miss in a given hash table using linear probing

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












$m$ is the size of the hash table and $n$ is the number of entries in the hash table.



We assume the hash function uniformly and independently distributes the keys among the values $0$ to $m-1$.



In Robert Sedgewick's book Algorithms 4th ed. He writes




If a cluster is of length $t$, then the expression $(t+(t-1)+ldots
+2+1)/m=t(t+1)/(2m)$ counts the contribution of that cluster to the grand total.
The sum of the cluster lengths is $n$, so, adding this cost for all
entries in the table, we find that the total average cost for a search
miss is $1+n/(2m)$ plus the sum of the squares of the lengths of the
clusters, divided by $2m$. Thus, given a table, we can quickly compute
the average cost of a search miss in that table.




My question is why do we add $n/(2m)$ to the expected number of probes. I understand the $1$ is added because every entry requires at least one probe, and adding the square of the length of a cluster (divided by $(2m))$ accounts for a search miss beginning within that cluster, but I don't see how the $n/(2m)$ is relevant.







share|cite|improve this question
























    up vote
    0
    down vote

    favorite












    $m$ is the size of the hash table and $n$ is the number of entries in the hash table.



    We assume the hash function uniformly and independently distributes the keys among the values $0$ to $m-1$.



    In Robert Sedgewick's book Algorithms 4th ed. He writes




    If a cluster is of length $t$, then the expression $(t+(t-1)+ldots
    +2+1)/m=t(t+1)/(2m)$ counts the contribution of that cluster to the grand total.
    The sum of the cluster lengths is $n$, so, adding this cost for all
    entries in the table, we find that the total average cost for a search
    miss is $1+n/(2m)$ plus the sum of the squares of the lengths of the
    clusters, divided by $2m$. Thus, given a table, we can quickly compute
    the average cost of a search miss in that table.




    My question is why do we add $n/(2m)$ to the expected number of probes. I understand the $1$ is added because every entry requires at least one probe, and adding the square of the length of a cluster (divided by $(2m))$ accounts for a search miss beginning within that cluster, but I don't see how the $n/(2m)$ is relevant.







    share|cite|improve this question






















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      $m$ is the size of the hash table and $n$ is the number of entries in the hash table.



      We assume the hash function uniformly and independently distributes the keys among the values $0$ to $m-1$.



      In Robert Sedgewick's book Algorithms 4th ed. He writes




      If a cluster is of length $t$, then the expression $(t+(t-1)+ldots
      +2+1)/m=t(t+1)/(2m)$ counts the contribution of that cluster to the grand total.
      The sum of the cluster lengths is $n$, so, adding this cost for all
      entries in the table, we find that the total average cost for a search
      miss is $1+n/(2m)$ plus the sum of the squares of the lengths of the
      clusters, divided by $2m$. Thus, given a table, we can quickly compute
      the average cost of a search miss in that table.




      My question is why do we add $n/(2m)$ to the expected number of probes. I understand the $1$ is added because every entry requires at least one probe, and adding the square of the length of a cluster (divided by $(2m))$ accounts for a search miss beginning within that cluster, but I don't see how the $n/(2m)$ is relevant.







      share|cite|improve this question












      $m$ is the size of the hash table and $n$ is the number of entries in the hash table.



      We assume the hash function uniformly and independently distributes the keys among the values $0$ to $m-1$.



      In Robert Sedgewick's book Algorithms 4th ed. He writes




      If a cluster is of length $t$, then the expression $(t+(t-1)+ldots
      +2+1)/m=t(t+1)/(2m)$ counts the contribution of that cluster to the grand total.
      The sum of the cluster lengths is $n$, so, adding this cost for all
      entries in the table, we find that the total average cost for a search
      miss is $1+n/(2m)$ plus the sum of the squares of the lengths of the
      clusters, divided by $2m$. Thus, given a table, we can quickly compute
      the average cost of a search miss in that table.




      My question is why do we add $n/(2m)$ to the expected number of probes. I understand the $1$ is added because every entry requires at least one probe, and adding the square of the length of a cluster (divided by $(2m))$ accounts for a search miss beginning within that cluster, but I don't see how the $n/(2m)$ is relevant.









      share|cite|improve this question











      share|cite|improve this question




      share|cite|improve this question










      asked Aug 9 at 15:13









      Ken Tjhia

      458




      458

























          active

          oldest

          votes











          Your Answer




          StackExchange.ifUsing("editor", function ()
          return StackExchange.using("mathjaxEditing", function ()
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
          );
          );
          , "mathjax-editing");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "69"
          ;
          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: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          noCode: true, onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2877310%2fexpected-number-of-probes-for-a-search-miss-in-a-given-hash-table-using-linear-p%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes










           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2877310%2fexpected-number-of-probes-for-a-search-miss-in-a-given-hash-table-using-linear-p%23new-answer', 'question_page');

          );

          Post as a guest













































































          這個網誌中的熱門文章

          tkz-euclide: tkzDrawCircle[R] not working

          How to combine Bézier curves to a surface?

          1st Magritte Awards