Lexicographically minimal string rotation: Difference between revisions

Content deleted Content added
Booth's Algorithm: Fixed critical bug in Booth algorithm as presented in the original paper
Booth's Algorithm: Fixed additional bug
Line 38:
<source lang="Python">
def LCS(S):
f = [-1 for c in S] # Failure function table
k = 0 # Rotation index
n = len(S)
f = [-1 for c in S] # Failure function table
k = 0 # RotationInitial rotation index
while S[k-1] == S[k] and (k-1) != 0:
k -= 1
k = (k+n)%n
for j in range(1, 2*n):
i = f[j-k-1]