A parking lot has 31 visitor spaces numbered from 0 to 30


Question: A parking lot has 31 visitor spaces, numbered from 0 to 30. Visitors are assigned parking spaces using the hashing function h(k) = k mod 31, where k is the number formed from the first three digits on a visitor's license plate.

a) Which spaces are assigned by the hashing function to cars that have these first three digits on their license plates: 317, 918, 007, 100, 111, 310?

b) Describe a procedure visitors should follow to find a free parking space, when the space they are assigned is occupied.

Another way to resolve collisions in hashing is to use double hashing. We use an initial hashing function h(k) = k mod p where p is prime. We also use a second hashing function g(k) = (k + 1) mod (p - 2).When a collision occurs, we use a probing sequence h(k, i) = (h(k) + i · g(k)) mod p.

Solution Preview :

Prepared by a verified Expert
Mathematics: A parking lot has 31 visitor spaces numbered from 0 to 30
Reference No:- TGS02365713

Now Priced at $10 (50% Discount)

Recommended (91%)

Rated (4.3/5)