|
ADS
Algorithms and Data Structures
|
The Lyndon factorization and the least rotation of a string, beyond the book. More...
#include "ADS/Contract.h"#include <cstddef>#include <string_view>#include <vector>#include "ADS/string/impl/Lyndon.tpp"Go to the source code of this file.
Namespaces | |
| namespace | ADS |
Functions | |
| bool | ADS::isLyndon (std::string_view S) |
| whether \( S \) is a Lyndon word, i.e., nonempty and smaller than all its proper suffixes, in \( O( n^2 ) \) by the definition | |
| std::vector< std::size_t > | ADS::lyndonFactorization (std::string_view S) |
| the starts of the factors of the Lyndon factorization of \( S \), by Duval | |
| std::size_t | ADS::leastRotation (std::string_view S) |
| the start of the least rotation of \( S \), 0 if \( S \) is empty | |
The Lyndon factorization and the least rotation of a string, beyond the book.
A Lyndon word is a nonempty string strictly smaller than all its proper rotations (equivalently, than all its proper suffixes), and every string \( S \) has one factorization
\[ S = w_1 w_2 \cdots w_k , \qquad w_1 \ge w_2 \ge \cdots \ge w_k , \]
into Lyndon words (Chen, Fox and Lyndon).
The contracts [see Contract.h]: the factors are Lyndon words in non-increasing order that give \( S \) back (an audit), and the rotation is not larger than any other (an audit, \( O( n^2 ) \)). The functions are defined in Lyndon.tpp.