Question: complete 1a,1b,1c,1d 1. Algorithm Understanding (12 points) Understand NAVE-STRING-MATCHER algorithm on p. 988 of the text. P and T are character arrays with the first
1. Algorithm Understanding (12 points) Understand NAVE-STRING-MATCHER algorithm on p. 988 of the text. P and T are character arrays with the first character of P & T stored in array cells of index 1. The meaning of the condition "P[1..m]==T[s+l..s+m]" in step 4 is "compare P[1] with T[s+1], P[2] with T[s+2],...,compare P[m] with T[stm) and if any of these comparisons returns FALSE then quit the character comparisons immediately and return FALSE otherwise continue and if all character comparisons succeed then return TRUE". 1a. If P=0001 and T=000010001010001, exactly how many character comparisons will the algorithm execute as a result of step 4 before it terminates? 1b. State all the values of s printed by the algorithm as a result of executing step 5 before it terminates: 1c. True or False? If |P=m and all characters in P are the same character cp, and T=n and all characters in T are the same character cp, msn, then if c, ==c, this represents a problem instance for which this algorithm will do the maximum number of character comparisons. Circle one: True False 1d. True or False? IfP-m and all characters in P are the same character c., and T-n and all characters in T are the same character cp, msn, then if c!= c., this represents a problem instance for which this algorithm will do the minimum number of character comparisons. Circle one: True False
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
