Is “Lexicographically Minimal Line Rotation” the same as “Lexicographic Minimum Suffix Search”?

Many may know the problem Lexicographically minimal string rotation. The solutions here are similar: How do I find the number of lexicographically minimal rotation of a string?


But I do not ask for a second decision. Instead, I want to ask another question: is this the same as the problem withfinding the lexicographical min suffix ?

For example, we have a string bbaaccaadd.

The lexicographic rotation of the minimum string will be "aaccaaddbb".

To find it, can I find the minimum suffix bbaaccaaddthat is equal aaccaaddand add the end of 2 "bb" at the end?


Are these two problems identical?

+4
source share
2 answers

To find it, can I find the minimal suffix bbaaccaadd, which is aaccaadd and add the end 2 "bb" at the end?

This would not always result in the correct minimum rotation. Take for example S = baa. Then the minimum suffix a, but the minimum rotation aab, not ab.

However, we can show that

min_rotation(S) = min_suffix(S + S + '∞') 

where '∞' is a character larger than each character in S.

Are these two problems identical?

, , . , min-suffix min-rotation . , , , . , S, . , Booth min-rotation .

+1

, "", , , .

, , min-rotation min-suffix , O (n) ( n - ).

min-rotation to min-suffix

min-rotation, .

min-suffix

: M . M, . , S '= min- (S), S', S, S.

: S1 S2, S1, S2. , T S2, S1 , T.

0

Source: https://habr.com/ru/post/1533426/


All Articles