|
ADS
Algorithms and Data Structures
|
Problems on strings solved by a suffix array [see SuffixArray.h] or a suffix tree [see SuffixTree.h], beyond the book (those of chapter 10, Searching Strings by Substring, of Ferragina's book and their classical companions). More...
#include "ADS/Contract.h"#include "ADS/string/SuffixArray.h"#include "ADS/string/SuffixTree.h"#include <algorithm>#include <cstddef>#include <cstdint>#include <optional>#include <string>#include <string_view>#include <utility>#include <vector>#include "ADS/string/impl/SuffixApplications.tpp"Go to the source code of this file.
Classes | |
| struct | ADS::CopyPhrase |
| a phrase of the parsing of Ziv and Lempel: copy length symbols from distance places back, then append next, if any More... | |
Namespaces | |
| namespace | ADS |
Functions | |
| std::pair< std::size_t, std::size_t > | ADS::longestRepeatedSubstring (const SuffixArray &SA) |
| the place and the length of a longest substring that occurs twice (0 and 0 if none) | |
| std::optional< std::size_t > | ADS::repeatedSubstring (const SuffixArray &SA, std::size_t L, std::size_t C) |
| the place of a substring of length \( L \) that occurs at least \( C \) times, if any | |
| std::uint64_t | ADS::distinctSubstrings (const SuffixArray &SA) |
| the number of distinct nonempty substrings, \( n ( n + 1 ) / 2 - \sum_r \mathit{LCP}[ r ] \) | |
| std::string | ADS::longestCommonSubstring (const std::vector< std::string > &S, std::size_t k) |
| a longest substring common to at least \( k \) of the strings \( S \) | |
| std::vector< std::pair< std::size_t, std::size_t > > | ADS::maximalRepeats (const SuffixTree &ST) |
| the maximal repeats, as the place of an occurrence and the length | |
| bool | ADS::proximity (const SuffixArray &SA, std::string_view P, std::string_view Q, std::size_t k) |
| whether an occurrence of \( P \) and one of \( Q \) start at most \( k \) places apart | |
| std::vector< std::size_t > | ADS::kMismatches (std::string_view T, std::string_view P, std::size_t k) |
| the places where \( P \) occurs in \( T \) with at most \( k \) mismatches | |
| std::vector< CopyPhrase > | ADS::lz77ByTree (std::string_view T) |
| the parsing of Ziv and Lempel of \( T \), the copies from the farthest occurrence, by the suffix tree | |
| std::string | ADS::decodeCopyPhrases (const std::vector< CopyPhrase > &Z) |
| the text of a parsing, each phrase copying its symbols one at a time, so that a copy may overlap the symbols it writes | |
Problems on strings solved by a suffix array [see SuffixArray.h] or a suffix tree [see SuffixTree.h], beyond the book (those of chapter 10, Searching Strings by Substring, of Ferragina's book and their classical companions).
A substring that occurs twice is a common prefix of two suffixes, and the suffixes that share a prefix of length \( L \) are a range of \( \mathit{SA} \) whose \( \mathit{LCP} \) entries are all at least \( L \): hence a scan of \( \mathit{LCP} \), or a visit of the internal nodes of the suffix tree, answers the questions on the repeats in \( O( n ) \) time.
The contracts [see Contract.h]: \( k \) is at least 1 and at most the number of strings for longestCommonSubstring(), \( C \) at least 1; the parsing decodes to the text (an audit). The functions are defined in SuffixApplications.tpp.