Computer Science EngineeringHardISRO SC (CS)

The naive string-matching algorithm slides pattern AAB over text AAAAAAAB, comparing characters left to right and abandoning an alignment at the first mismatch. The total number of character comparisons is:

  1. A. 19
  2. B. 17
  3. C. 18
  4. D. 8

Correct answer: C. 18

Sum the comparisons made at each alignment: 18.

More Algorithms, Data Structures & Programming (ISRO CS) questions

Exams that ask this topic