Question: Also provide the analysis of the algorithms. Consider the problem of looking for a m times m pattern P[1..m, 1..m] in a n times n

 Also provide the analysis of the algorithms. Consider the problem of

Also provide the analysis of the algorithms.

Consider the problem of looking for a m times m pattern P[1..m, 1..m] in a n times n matrix M[1..n, 1..n] of characters. Find all locations (i, j) in S where there is an occurrence of the pattern. That is, S[i + k, j + l] = P[k + 1, l + 1], where 1 lessthanorequalto k, l lessthanorequalto m. When looking for P in the matrix, the pattern may be shifted vertically and horizontally, but it may not be rotated. Here's an example. Suppose P[1.. 2, 1.. 2] and S[1.. 4, 1.. 4], where Sigma = {a, b, c, ellipsis, z} are as follows. P = 1 2(1 h m 2 I n) S = 1 2 3 4 (1 a f h m 2 b g i n 3 c h m l 4 d i n o 5 e j k p) Then, the pattern P is found starting at locations (2, 3) and (3, 1) in S. (a) Give a brute force algorithm to solve this problem. (b) Give an O(n^2) algorithm that extends the Rabin-Karp algorithm in order to solve this

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!