Discussion
While hashing 5 integer keys namely 5, 12, 23, 32, 104 using the hash function h(key) = key % 10 into a hash table with 10 buckets the number of keys that will collide is
Answer: C
The number of keys that collide is 2.
Apply h(key) = key % 10 to each key:
| Key | 5 | 12 | 23 | 32 | 104 |
|---|---|---|---|---|---|
| Bucket | 5 | 2 | 3 | 2 | 4 |
Only bucket 2 receives more than one key: 12 and 32 both end in 2. So 2 keys collide. Counting the collision as one event gives 1, the trap; 0 ignores the shared bucket and 3 counts a key that has a bucket to itself.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development