Asymptotic-Complexity
October 12, 2023
Algorithms
October 12, 2023
Asymptotic-Complexity
October 12, 2023
Algorithms
October 12, 2023

Algorithms

Question 24
Suppose we are given n keys, m hash table slots, and two simple uniform hash functions h 1 and h 2 . Further suppose our hashing scheme uses h 1 for the odd keys and h 2 for the even keys. What is the expected number of keys in a slot?
A
m/n
B
n/m
C
2n/m
D
n/2m
Question 24 Explanation: 
For n keys and m elements without any condition the expected number of elements in a slot are n/m.
How?
For 1st element the probability of key1 ends up in slot 1 is 1/m.
For 2nd element the probability of key2 ends up in slot 2 is 1/m
..
..
For nth element the probability of keyn ends up in slot n is 1/m
Hence expected number of elements in a slot is:
1/m+1/m+… (n times)= n/m
In the given question h1 is for elements at even sequence position and h2 is for odd number of sequence positions. This will not affect the overall probability.
Hence here also it is n/m
Correct Answer: B
Question 24 Explanation: 
For n keys and m elements without any condition the expected number of elements in a slot are n/m.
How?
For 1st element the probability of key1 ends up in slot 1 is 1/m.
For 2nd element the probability of key2 ends up in slot 2 is 1/m
..
..
For nth element the probability of keyn ends up in slot n is 1/m
Hence expected number of elements in a slot is:
1/m+1/m+… (n times)= n/m
In the given question h1 is for elements at even sequence position and h2 is for odd number of sequence positions. This will not affect the overall probability.
Hence here also it is n/m
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!