Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7536769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:39:58+00:00 2026-05-30T06:39:58+00:00

A suffix array will index all the suffixes for a given list of strings,

  • 0

A suffix array will index all the suffixes for a given list of strings, but what if you’re trying to index all the possible unique substrings? I’m a bit new at this, so here’s an example of what I mean:

Given the string

abcd

A suffix array indexes (at least to my understanding)

(abcd,bcd,cd,d)

I would like to index (all the substrings)

(abcd,bcd,cd,d,abc,bc,c,ab,b,a)

Is a suffix array what I’m looking for? If so, what do I do to get all the substrings indexed? If not, where should I be looking? Also what would I google for to contrast “all substrings” vs “suffix substrings”?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T06:40:00+00:00Added an answer on May 30, 2026 at 6:40 am

    The suffix array does what you need already, because every substring is a prefix of one of the suffixes. Specifically, given your suffix array

    abcd
    bcd
    cd
    d

    and assume you are looking for substring “bc”, then you can find that by looking for all suffixes that start with “bc” (there is only one in this case, “bcd”). Since a suffix array is lexicographically sorted, finding all suffixes that share a certain prefix corresponds to a binary search across the suffix array, and the result will be one continuous range of entries of the suffix array.

    However, there are optimised search methods using the suffix array combined with auxiliary data structures, such as the LCP (longest-common prefix) array, or wavelet trees. See Navarro’s 2007 survey for a description of such methods (DOI 10.1145/1216370.1216372).

    To take into account the comments made below, I suggest combining each suffix with the number of substrings it represents. In a simple example like the above this would be

    4 abcd
    3 bcd
    2 bc
    1 d
    

    because, for example, the first suffix “abcd” represents the 4 substrings “a”, “ab”, “abc”, “abcd”. However, in a more complex example, say for the string “abcabxdabe”, the first two entries of the suffix array would be

    10 abcabxdabe
    1 abe
    

    because the second entry represents substrings “a”, “ab” and “abe”, but “a” and “ab” are also represented by the first entry.

    How to calculate the number of substrings an entry represents? –> The length of the suffix minus the length of the longest prefix it has in common with the previous suffix. E.g. in the “abe” example, that is 3 (its length) minus 2 (the length of “ab”, the longest prefix it shares with the previous entry). So these numbers can be generated in one pass over the suffix array, and even faster if you have also generated the LCP (longest-common prefix) array.

    The next step would be to generate accumulated counts:

    10 abcabxdabe
    11 abe
    16 abxdabe
    ...
    

    and then to find an efficient way to make use of the accumulated counts. E.g. if you want to get the 13th substring lexicographically, you’d have to find the first entry that has an accumulated count greater than or equal to 13. That would be “16 abxdabe” above. Then remove the prefix it shares with the previous entry (yields “xdabe”), and then jump to the position after the 2nd character (because the previous entry has accumulated count 11, and 13-11==2), so you get “abxd” as the 13th substring lexicographically.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to add a .html suffix at the end of all strings
I'm doing some work with Ukkonen's algorithm for building suffix trees, but I'm not
In ASP.NET MVC, we're required to use the suffix Controller for all controllers. This
In C#, Say you have an array of strings, which contain only characters '0'
Array to sort has approximately one million strings, where every string can have length
I have created a suffix array using the Princeton implementation. However, my basic text
I'm trying to initialize inline an array of UInt16. For int I can do
I'm coding a suffix array sorting, and this algorithm appends a sentinel character to
I'm trying to pass the array to the generate function and use its elements
I am trying to figure out how to iterate over an array which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.