I recently studied about string matching, and was inspired to think of a similar problem. Let p be a string of m characters and t be a text of n characters. Now the problem is to find out if p occurs in t in the following way: there exists an i in the range [0, n-1] such that:
p[ j ] = t [ i + j ] for j = 0, 1, ... ,m - 1,
where i + j is computed modulo n. As an example, in normal string matching, ABCD would not occur in CDEFAB, but you can see that in the above-defined problem, ABCD would occur in CDEFAB, i = 4 in this case.
Is there any linear-time algorithm to determine if a pattern p occurs in t? And has this problem been treated before?
Thanks in advance