Question: 5. The string search problem (6 points) We discussed the sliding window strategy for string search in class, in which, if you are searching for

5. The string search problem (6 points) We discussed the "sliding window" strategy for string search in class, in which, if you are searching for a string of length min a text of length n, msn, you compare S with a m-length substring of T starting with its first character (at index 1), and if a match is not found sliding that m-length "window" one character to the right on T and comparing the m-length substring at indexes 2...(m+1) of T with S, and repeating this until the last m characters of T are compared with S (unless S is found in T earlier, in which case the search ends). Given S and T, where St=m and T|=n and msn, what is the minimum number of character-to-character comparisons that an algorithm implementing this strategy has do to find Sin T? If S="cat" provide a T of length 6 for which this minimum number applies: Given S and T, where S =m and T =n and msn, what is the maximum number of character-to-character comparisons that an algorithm implementing this strategy has do to find S in T? If S="cat" provide a T of length 6 for which this maximum number applies: Given S and T, where Si=m and T|=n and msn, what is the maximum number of character-to-character comparisons that an algorithm implementing this strategy has do to if S is not in T? If S="cat" provide a T of length 6 for which this maximum number applies
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
