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 6066231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:28:43+00:00 2026-05-23T09:28:43+00:00

I am trying to find an algorithm that culd return the length of the

  • 0

I am trying to find an algorithm that culd return the length of the shortest cyclic sub string in a larger cyclic string.

A cyclic string would be defined as a concatenation of tow or more identicle strings, e.g. “abababab”, or “aaaa”…

Now in a given for example a string T = “abbcabbcabbcabbc” there is a cycle of the pattern “abbc” but the shortest cyclic sub string would be “bb”.

  • 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-23T09:28:43+00:00Added an answer on May 23, 2026 at 9:28 am

    If you’re just looking for a substring that appears more than once:

    Build a Suffix tree from the string.

    While creating the suffix tree, you can count re-occurrences of every substring and save it on the number of occurrences on the node.

    Then just do a BFS search on the tree (which will give you a layered search, from shorter to longer strings) and find the first substring which is longer than 1 that occurred more than once.

    Total complexity: O(n) where n is the length of the string

    Edit:

    The paths from the root to the leaves
    have a one-to-one relationship with
    the suffixes of S

    You can implement the tree that each node contains one letter, that will give you better granularity and allow you to see all the substrings by length.

    Here’s a suffix tree of banana where every node contains one letter, you can see that you have all the substrings there.
    enter image description here

    If you’ll look at the applications section of the suffix tree, you’ll see that it is used for exactly this kind of tasks – finding stuff about substrings.

    Look at the image from the root, you can see ALL the substrings start from the root (BFS list):

    b
    a
    n
    ba
    an
    na
    ban
    ana
    nan
    bana
    anan
    nana
    banan
    anana
    banana
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write an algorithm that will find the set of all vertices
I'm trying to find some sort of a good, fuzzy string matching algorithm. Direct
I'm trying to develop a genetic algorithm that will find the most efficient way
What I'm trying to do is find an algorithm that can I can implement
I'm trying to implement a 6 Degrees-style algorithm, in that I'm trying to find
I'm trying to find a function lng = f(lat) that would help me draw
I'm trying to make an algorithm that will find the most efficient ordering for
I am trying to find an algorithm to count from 0 to 2 n
I am trying to find a fast algorithm with modest space requirements to solve
I'm trying to figure out an algorithm to find the highest 2 numbers in

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.