Discussion
Working modulo q = 11, how many spurious hits does the Rabin Karp matcher encounter in the text T = 459263781 when working for the pattern β = 37 :
Answer: C
The matcher encounters 4 spurious hits.
The pattern's hash is 37 mod 11 = 4. Rabin-Karp compares this with the hash of every two-digit window of the text 459263781:
| 45 | 59 | 92 | 26 | 63 | 37 | 78 | 81 |
| 1 | 4 | 4 | 4 | 8 | 4 | 1 | 4 |
Five windows hash to 4: 59, 92, 26, 37 and 81. Only 37 is a real match. The other four, 59, 92, 26 and 81, are spurious hits: their hash agrees with the pattern's but the digits do not.
Counting the true match as well gives 5, which is the trap in option D.
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