Content deleted Content added
m →Shiloach's Fast Canonization Algorithm: edited grammar |
Modified markup to favor bold/italics instead of in-sentence math markup. |
||
Line 18:
==Algorithms==
===The Naive Algorithm===
The naive algorithm for finding the lexicographically minimal rotation of a string is to iterate through successive rotations while keeping track of the most lexicographically minimal rotation encountered. If the string is of length
===Booth's Algorithm===
Line 56:
f[j-k] = i+1
</source>
Of interest is that removing all lines of code which modify the value of
===Shiloach's Fast Canonization Algorithm===
Line 73:
| author = Yossi Shiloach }}
</ref>
proposed an algorithm improving on Booth's result in terms of performance. It was observed that if there are '''''q''''' equivalent lexicographically minimal rotations of a string of length '''''n''''', then the string must consist of ''q'' equal substrings of length '''''d=n/q'''''. The algorithm requires only '''''n + d/2''''' comparisons and constant space in the worst case.
The algorithm is divided into two phases. The first phase is a quick sieve which rules out indices that are obviously not starting locations for the lexicographically minimal rotation. The second phase then finds the lexicographically minimal rotation start index from the indices which remain.
|