CSE 2012-Design and Analysis of Algorithms Practice Problem Sheet (String Matching Problem)
CSE 2012-Design and Analysis of Algorithms Practice Problem Sheet (String Matching Problem)
1
6. Given j texts T1 [1, ..., n], T2 [1, ..., n],... Tj [1, ..., n], of length n and k Pat-
terns P1 [1, ..., m], P2 [1, ..., m], ..., Pk [1, ..., m], modify the Robin-Karp al-
gorithm to compute the occurrence of all the valid shifts of all the patterns
in all the texts. Analyse your running time with time-complexity.
7. Given two texts T , T ′ , design a linear-time algorithm to determine whether
the T is a cyclic rotation of T ′ . For example, ‘car’ is the cyclic rotation
of ‘arc’ since ‘car’ can be obtained by a cyclic rotation of the symbols in
‘arc’. Analyse your running time with time-complexity.
8. Consider the pattern P and the text T . Given the ‘Prefix-function Table‘
of the string P T (π table for the string PT ), design an algorithm to
compute the valid shifts of P in T . Analyse your running time with time-
complexity.