Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A bucket is simply a fast-access location (like an array index) that is the the result of the hash function.</p> <p>The idea with hashing is to turn a complex input value into a different value which can be used to rapidly extract or store data.</p> <p>Consider the following hash function for mapping people's names into street addresses.</p> <p>First take the lower-cased initials from the first and last name and turn them both into numeric values (0 through 25, from 'a' through 'z'). Multiply the first by 26 and add the second, and this gives you a value from 0 to 675 (26 * 26 distinct values, or bucket IDs).</p> <p>This bucket ID is then to be used to store or retrieve the information. Now you can have a perfect hash (where each allowable input value maps to a <em>distinct</em> bucket ID) so that a simple array will suffice for the buckets. In other words, you maintain an array of 676 street addresses and use the bucket ID to find the one you want:</p> <pre><code>+-------------------+ | George Washington | -&gt; hash(GW) +-------------------+ | +-&gt; GwBucket[George's address] +-------------------+ | Abraham Lincoln | -&gt; hash(AL) +-------------------+ | +-&gt; AlBucket[Abe's address] </code></pre> <p>Or you can have an <em>imperfect</em> hash (such as one where John Smith and Jane Seymour would end up with the same bucket ID).</p> <p>In that case, you need a more complex backing data structure than a simple array, to maintain a <em>collection</em> of addresses. This could be as simple as a linked list, or as complex as yet <em>another</em> hash:</p> <pre><code>+------------+ +--------------+ | John Smith | | Jane Seymour | +------------+ +--------------+ | | V V hash(JS) hash(JS) | | +-----&gt; JsBucket &lt;----+ \/ +-----------------------------------+ | "John Smith -&gt; [John's address] | | "Jane Seymour -&gt; [Jane's address] | +-----------------------------------+ </code></pre> <p>Then, as well as the initial hash lookup, an extra level of searching needs to be carried out within the bucket itself, to find the specific information.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload