CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    May 2008
    Posts
    1

    Longest Palindrome in String

    I am looking for O(N) solution to the problem of finding longest palindrome in a string
    in linear time-complexity...
    I got a link in which this problem is described....but i m not able to understood it clearly
    (how it reduces from O(N^2) to O(N) complexity...)
    Link: http://www.akalin.cx/2007/11/28/find...n-linear-time/
    I am very confused with "what is the palindromic proper suffix and how we find it out"
    also how "given a current center, the longest palindrome around that center, and a list of the lengths of the longest palindromes around the centers to the left of the current center, can we figure out the new center to consider and extend the list of longest palindrome lengths up to that center efficiently?"
    Please, reply.
    PS: Please ignore the suffix tree approach

  2. #2
    Join Date
    Dec 2009
    Posts
    145

    Re: Longest Palindrome in String

    You problem is supposed to be another form of longest common substring, which the suffix tree seems best fitted in terms of time complexity, with only trade-off for space and extra steps in tree building. The current O(n^2) looks founded and widely used until some striking alternative approach hits the journal in the very near future, I hope.

  3. #3
    Join Date
    May 2011
    Posts
    4

    Re: Longest Palindrome in String

    Hi, I found this link
    http://portal.acm.org/citation.cfm?id=1840177
    it is computeing longest palindrome in linear time and space.

    But it asks me to pay. Anyone knows its content, pseudoalgorithm to do that ?

  4. #4
    Join Date
    Feb 2011
    Location
    United States
    Posts
    1,016

    Re: Longest Palindrome in String

    Best Regards,

    BioPhysEngr
    http://blog.biophysengr.net
    --
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  5. #5
    Join Date
    May 2011
    Posts
    4

    Re: Longest Palindrome in String

    They provided translated code that works incorrectly,
    For this string
    dcfcdhihijkjihjfccccccccccabcdefggfedcba
    the last C++ source code returns cccccccccc, I think this is the purpose of the program, as the second loop only counts indices in case of equal characters encountered to retrieve its length, there is no check for palindromes. that is why it takes O(n). (Just my brief reading)

  6. #6
    Join Date
    Aug 2008
    Posts
    112

    Re: Longest Palindrome in String

    Well the last source code is written in C#,
    hi,,,

  7. #7
    Join Date
    Feb 2011
    Location
    United States
    Posts
    1,016

    Re: Longest Palindrome in String

    Oh, sorry; I wasn't reading carefully. I read your main post a few days ago and neglected to see that you included the same link I gave you. >__<
    Best Regards,

    BioPhysEngr
    http://blog.biophysengr.net
    --
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured