Consider a double hashing scheme in which the primary hash function is...
For double hashing we use the formula as (h1(k) + i h2(k ))% table size where i denotes probe value.
h1(k) = 90% 23 = 21
h2(k) = 1 + k % 19
= 1 + 90 % 19 = 15
For probe 1 the value of i is 1 thus, (21 + 13) % 23 = 13
View all questions of this test
Consider a double hashing scheme in which the primary hash function is...
The given double hashing scheme uses two hash functions to determine the address of a key in a hash table. Let's break down the process step by step to understand why the address returned by probe 1 for key value k = 90 is 13.
1. Primary Hash Function (h1):
The primary hash function, h1(k) = k mod 23, maps the key value to an index in the range [0, 22]. In this case, h1(90) = 90 mod 23 = 21.
2. Secondary Hash Function (h2):
The secondary hash function, h2(k) = 1 (k mod 19), always returns 1. This function is used to determine the probe offset when there is a collision.
3. Probe Sequence:
The probe sequence is generated by repeatedly applying the secondary hash function with increasing probe numbers until an empty slot is found in the hash table. The probe sequence starts at probe 0.
To find the address for key value k = 90, we need to determine the probe sequence. Since h2(k) always returns 1, the probe sequence for k = 90 will be as follows:
Probe 0: h1(k) + 0 * h2(k) = 21 + 0 * 1 = 21
Probe 1: h1(k) + 1 * h2(k) = 21 + 1 * 1 = 22
Probe 2: h1(k) + 2 * h2(k) = 21 + 2 * 1 = 23
Probe 3: h1(k) + 3 * h2(k) = 21 + 3 * 1 = 24
Probe 4: h1(k) + 4 * h2(k) = 21 + 4 * 1 = 25
...
4. Address returned by Probe 1:
From the probe sequence above, we can see that at probe 1, the address is 22. However, since the table size is 23, we need to wrap around the address. Therefore, the address returned by probe 1 will be 22 % 23 = 13.
Hence, the correct answer is 13.