Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  Consider a hash function that distributes key... Start Learning for Free
Consider a hash function that distributes keys uniformly. The hash table size is 20. After hashing of how many keys will the probability that any new key hashed collides with an existing one exceed 0.5.
  • a)
    5
  • b)
    6
  • c)
    7
  • d)
    10
Correct answer is option 'B'. Can you explain this answer?
Verified Answer
Consider a hash function that distributes keys uniformly. The hash tab...
Probability of hashed 1st key = 20/20 = 1
Probability of hashed 2nd key with no collision = 19/20
Probability of hashed 3rd key with no collision = 18/20
Similarly, probability of hashed rth key with no collision 
According to question: Probability of hashed (n + 1)th key with collision > 0.5 Probability of hashed (n + 1)th key with collision
P(C) = 1 - P (Till (nth) no collision)


19 x 18 x 17 .... x 20 - n + 1 < 0.5 x (20)n-1
By put n = 5, we get 0.581, for n = 6, we get 0.436, which satisfies the equation.
View all questions of this test
Most Upvoted Answer
Consider a hash function that distributes keys uniformly. The hash tab...
Probability of Collision in a Hash Table
To understand the answer to this question, let's first understand how the probability of collision in a hash table is calculated.

Given a hash function that distributes keys uniformly, the probability of a collision between two keys is determined by the formula:

P(collision) = 1 - P(no collision)

Where P(no collision) is the probability that a new key hashed does not collide with any existing key in the hash table.

Calculating the Probability of No Collision
In a hash table with a size of 20, the probability of no collision for the first key is 1 (since there are no existing keys).

For the second key, the probability of no collision is 19/20, as it can be hashed to any of the 19 remaining empty slots.

For the third key, the probability of no collision is 18/20, as it can be hashed to any of the 18 remaining empty slots.

Similarly, for the fourth key, the probability of no collision is 17/20.

In general, for the nth key, the probability of no collision is (20 - (n-1))/20.

Finding the Number of Keys for P(collision) > 0.5
We want to find the number of keys after which the probability of collision exceeds 0.5.

So, we need to find the smallest value of n for which P(no collision) < />

Using the formula above, we can calculate the probabilities for different values of n:

P(no collision) for n = 1: 1
P(no collision) for n = 2: 19/20
P(no collision) for n = 3: 18/20
P(no collision) for n = 4: 17/20

Continuing this calculation, we find:

P(no collision) for n = 5: 16/20
P(no collision) for n = 6: 15/20
P(no collision) for n = 7: 14/20

Therefore, for n = 7, the probability of collision exceeds 0.5, as P(no collision) = 14/20 = 0.7.

Conclusion
Based on the calculation above, after hashing 6 keys, the probability that any new key hashed collides with an existing one exceeds 0.5. Therefore, the correct answer is option 'b' - 6.
Explore Courses for Computer Science Engineering (CSE) exam

Similar Computer Science Engineering (CSE) Doubts

Question Description
Consider a hash function that distributes keys uniformly. The hash table size is 20. After hashing of how many keys will the probability that any new key hashed collides with an existing one exceed 0.5.a)5b)6c)7d)10Correct answer is option 'B'. Can you explain this answer? for Computer Science Engineering (CSE) 2025 is part of Computer Science Engineering (CSE) preparation. The Question and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus. Information about Consider a hash function that distributes keys uniformly. The hash table size is 20. After hashing of how many keys will the probability that any new key hashed collides with an existing one exceed 0.5.a)5b)6c)7d)10Correct answer is option 'B'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2025 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Consider a hash function that distributes keys uniformly. The hash table size is 20. After hashing of how many keys will the probability that any new key hashed collides with an existing one exceed 0.5.a)5b)6c)7d)10Correct answer is option 'B'. Can you explain this answer?.
Solutions for Consider a hash function that distributes keys uniformly. The hash table size is 20. After hashing of how many keys will the probability that any new key hashed collides with an existing one exceed 0.5.a)5b)6c)7d)10Correct answer is option 'B'. Can you explain this answer? in English & in Hindi are available as part of our courses for Computer Science Engineering (CSE). Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.
Here you can find the meaning of Consider a hash function that distributes keys uniformly. The hash table size is 20. After hashing of how many keys will the probability that any new key hashed collides with an existing one exceed 0.5.a)5b)6c)7d)10Correct answer is option 'B'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Consider a hash function that distributes keys uniformly. The hash table size is 20. After hashing of how many keys will the probability that any new key hashed collides with an existing one exceed 0.5.a)5b)6c)7d)10Correct answer is option 'B'. Can you explain this answer?, a detailed solution for Consider a hash function that distributes keys uniformly. The hash table size is 20. After hashing of how many keys will the probability that any new key hashed collides with an existing one exceed 0.5.a)5b)6c)7d)10Correct answer is option 'B'. Can you explain this answer? has been provided alongside types of Consider a hash function that distributes keys uniformly. The hash table size is 20. After hashing of how many keys will the probability that any new key hashed collides with an existing one exceed 0.5.a)5b)6c)7d)10Correct answer is option 'B'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Consider a hash function that distributes keys uniformly. The hash table size is 20. After hashing of how many keys will the probability that any new key hashed collides with an existing one exceed 0.5.a)5b)6c)7d)10Correct answer is option 'B'. Can you explain this answer? tests, examples and also practice Computer Science Engineering (CSE) tests.
Explore Courses for Computer Science Engineering (CSE) exam
Signup to solve all Doubts
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev