Question
3. Algorithm Correctness (10 points) A different modification of NAVE-STRING-MATCHER the effectively implements the same strategy is given below. But it is an incorrect algorithms.
3. Algorithm Correctness (10 points)
A different modification of NAVE-STRING-MATCHER the effectively implements the same strategy is given below. But it is an incorrect algorithms.
MODIFIED-NAVE-STRING-MATCHER(T: array [1..n] of char; P: array [1..m] of char, , mn)
1 n = T.length
2 m = P.length
3 s = 0
4 while s 5 for i = 1 to m 6 if P[i] != T[s+i] then 7 s = s+i 8 exit the i-loop and go to step 4 9 print "pattern occurs with shift" s 10 s = s+m Prove by Counterexample that it is incorrect by providing a problem instance for which it fails and explaining why it fails (complete the parts of the proof below). Problem Instance: P= T= Correct answer or answers (correct values of shift s): The value or values of s that the algorithm will print: Brief and precise explanation of why the algorithm prints incorrect answers for the given problem instance:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started