1,679 views
0 0 votes

Consider the following, five binary strings of length 8.

01010010, 11011011, 10011010, 11111011, 01110010

A hash table of size M = 8 (0 to 7) is using open addressing for hashing the binary strings.  Assume finding an empty slot directly without collision or after collision is also a probe. Calculate the total number of probes that occur while hashing five strings using linear probing.

    1 Answer

    Best answer
    5 5 votes
    In linear probing if the hashed location is not empty, a linear probe is done to find an empty slot.

    Assuming mod 8 function for hashing

    01010010 mod 8 = 010 = 2 (1 probe, goes to slot 2)

    11011011 mod 8 = 011 = 3 (1 probe, goes to slot 3)

    10011010 mod 8 = 010 = 2 (3 probes, goes to slot 4, unsuccessful probes at slots 2 and 3)

    11111011 mod 8 = 011 = 3 (3 probes, goes to slot 5, unsuccessful probes at slots 3 and 4)

    01110010 mod 8 = 010 = 2 (5 probes, goes to slot 6, unsuccessful probes at slots 2, 3, 4, and 5)

    So, total number of probes = 13

    http://webdocs.cs.ualberta.ca/~holte/T26/open-addr.html
    • selected by
    Position:
    Show:

    Related questions

    61 61 votes
    5 answers 5 answers
    25.4k
    25.4k views
    Arjun asked Feb 12, 2020
    25,414 views
    Consider a double hashing scheme in which the primary hash function is $h_1(k)= k \text{ mod } 23$, and the secondary hash function is $h_2(k)=1+(k \text{ mod } 19)$. Ass...
    3 3 votes
    1 1 answer
    182
    182 views
    GO Classes asked Aug 31
    182 views
    An initially empty hash table $\text{HT}$ has length $11$.The hash function is:$H(key)=key \bmod 7$Collisions are resolved using linear probing.The following keys are ins...
    1 1 vote
    2 2 answers
    741
    741 views
    vinayak_chandra asked Jan 31, 2025
    741 views
    A hash table can store a maximum of ten records. Currently there are records in locations 1, 3, 4, 7, 8, 9, 10. The probability of a new record going into location 2, wit...
    2 2 votes
    1 1 answer
    500
    500 views