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:
- A. 19
- B. 17
- C. 18
- D. 8
Correct answer: C. 18
Sum the comparisons made at each alignment: 18.
Practise more Algorithms, Data Structures & Programming (ISRO CS) questionsAlgorithms, Data Structures & Programming (ISRO CS): notes and key points
More Algorithms, Data Structures & Programming (ISRO CS) questions
- A binary counter starts at 0 and is incremented 500 times. The total number of bit flips (0->1 and 1->0) over all increments is:
- The max-heap [92, 49, 62, 39, 40, 19, 28, 36, 38] undergoes one extract-max (last element moved to the root, then sifted down). The…
- The worst-case number of key comparisons binary search makes on a sorted array of 100 elements (counting one three-way comparison per…
- Trace this C function. int f(int n){ if(n==0) return 1; return nf(n-1) - f(n/2); } (integer division) What does f(6) return?
- Using the Master theorem (extended form), the solution of T(n) = 27T(n/3) + n^3 is:
- Using the Master theorem (extended form), the solution of T(n) = 2T(n/3) + n is: