Question
Suppose we are given keys, hash table slots, and two simple uniform hash functions and . Further suppose our hashing scheme uses for the odd keys and for the even keys. What is the expected number of keys in a slot?
Official answer and solution
- Official answer
- B
- From
- Official GATE 2022 answer key
Solution
Apply indicator random variables and linearity of expectation under simple uniform hashing.
Let be the set of odd keys and be the set of even keys, with and such that .
Under simple uniform hashing:
- Each key is hashed by into any slot with probability .
- Each key is hashed by into any slot with probability .
Let be the number of keys hashed into slot . Defining indicator variables if key hashes to slot and otherwise:
Thus, regardless of the distribution of odd and even keys, the expected number of keys in any given slot is .
Option (B)
Dividing by believing that two hash functions double the effective table size or halve the expected load.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2022 Computer Science and Information Technology (CS)
- Question
- 16 of 65
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.