CSCI 3650
Analysis of Algorithms
Summer 2003
Assignment 7

Definition. A cyclic permutation of a string x1...xn is a string xi...xnx1...xi-1, for some i.

Describe an algorithm that takes two strings of the same length n and tells whether one is a cyclic permutation of the other. For example, if the input strings are "abaccd" and "accdab", the answer should be yes.

Your algorithm must run in time O(n), where n is the length of the strings. Use the Knuth/Morris/Pratt algorithm. You do not need to describe how that algorithm works. Just use it.