Questions tagged [suffix-array]

20 questions
18
votes
3 answers

Computing the longest common substring of two strings using suffix arrays

After I learned how to build a suffix array in $O(N)$ complexity, I am interested in discovering the applications of the suffix arrays. One of these is finding the longest common substring between two strings, in $O(N)$ time. I found on the internet…
12
votes
1 answer

Counting number of sums from contiguous subarrays of an array

We are given an array $a[1 \ldots n]$ with all $a[i]>0$. Now we need to find how many distinct sums can be formed from its subarrays (where a subarray is a contiguous range of the array, i.e., $a[j\ldots k]$ for some $j,k$, the sum is the sum of all…
Salena
  • 253
  • 2
  • 7
5
votes
0 answers

Number of distinct substrings

I know how to find the number of distinct substrings for a string (using suffix arrays) and I was wondering if there was a way to find this number for all of its prefixes. I already have an $O(N^2)$ solution: computing the suffix array and lcp array…
4
votes
1 answer

Number of distinct substrings in a string

From what I have come to understand, the best way to implement it is to use the suffix array $S$ of the string $w$ and its LCP-array (Longest Common Prefix) $L$. The answer can be obtained by $$ \sum_{i=1}^{|w|} \left( |S[i]| -L[i-1]…
3
votes
1 answer

String matching for all suffixes

Given a string $(a_0,a_1,\ldots a_n)$. I want to find the length of the longest common prefix of the substrings $(a_0,a_1,\ldots a_{n-1})$ and $(a_1,a_2,\ldots a_n)$. I know this has atleast $O(n)$ complexity. Lets call this operation as…
Satvik
  • 131
  • 2
3
votes
3 answers

Longest common substring many strings to one

I'd like to find longest common substring (occurrences, start index) between one string and many others. For example source string - "abcdefghijklmncdop" other strings - ["cd", "ghi", "mn", "zw", "cdewxyz"]. Expected result -(original string,…
Fimka
  • 31
  • 2
3
votes
1 answer

Find shortest prefix to generate original string by overlapping

Given a string $S$, I want to find the prefix string $P$ of shortest length, such that the original string $S$ can be generated by concatenating copies of $P$ (where overlapping is allowed). For example, if $S = atgatgatatgat$, I want to find $P =…
2
votes
0 answers

Fast generalised suffix array construction: lower than O(n^2 log n)

There is a lot in the literature about linear time constructions for suffix arrays; DC3, radixSA46, and more... However, these, I believe, are only for suffix arrays; with a single string input. Are there fast algorithms for generalised suffix…
izaak
  • 21
  • 1
2
votes
2 answers

Storage cost of a suffix array

MY question is about storage complexity of a suffix array. According to textbooks it is O(n) with an exact cost that approximates 4n. However a suffix array of a string of length n is an n-size integer array, along an index that maps each substring…
curious
  • 231
  • 1
  • 4
2
votes
0 answers

What is an easy-to-implement linear or non-quadratic suffix array construction algorithm?

The algorithm described here in "Linear Work Suffix Array Construction" (2006) has compact C++ code that is too abstract for me to follow. Is that still the current easy-to-implement linear algorithm? If no, please point out that other algorithm. If…
1
vote
0 answers

Efficient generalized suffix array/tree construction for prefix trees

Is there any algorithm that can efficiently construct a generalized suffix tree or array (or something similar) for a set of strings represented by a prefix tree (trie)? In particular, I'm wondering: How time-efficient an algorithm for this can…
user541686
  • 1,187
  • 1
  • 10
  • 17
1
vote
0 answers

DC3/Skew Suffix Array Algorithm doesn't work for specific cases

When applying the DC3/Skew algorithm to the string yabadabado, I can't quite get it to sort correctly. This issue happens in other cases, but this is a short example to show it. This first table is for reference: These are the triples of R12 We…
Brother58697
  • 111
  • 1
1
vote
0 answers

Why is converting a suffix tree to a suffix array not O(nklogk) time

Let's say that we have computed a suffix tree in O(n) time, and wish to use this to create a suffix array. According to wikipedia: A suffix tree can be built in $O(n)$ and can be converted into a suffix array by traversing the tree depth-first also…
Recessive
  • 143
  • 5
0
votes
1 answer

Suffix array construction algorithm linear complexity constant

A non-recursive linear Suffix Array construction algorithm is presented in this thesis: Linear-time Suffix Sorting. The author claims that, overall, the algorithm runs at $O(n)$. While it is well explained, there are only hints that this is case.…
Kazh
  • 3
  • 3
0
votes
2 answers

Finding A String Using A Suffix Array/Table

Is it possible to find out a string only having its corresponding suffix array/table and knowing that the string contains only, for instance, letters "f", "g", "r"? If so, how is that possible?
l..
  • 149
  • 1
1
2