brute force... http://codepad.org/D07BNo91 There are some checks to help reduce O(n^2), so I want to say.. O(1.5n) ? =)
#output for str = 'abaccddccefe' #ccddcc 6 #for str = 'abraxyzarba' #a 1 On Aug 22, 1:09 pm, uma <umai...@gmail.com> wrote: > can yo tell exactly , how the suffix tree is used for finding > palindromes? > > On Aug 22, 3:58 am, WgpShashank <shashank7andr...@gmail.com> wrote: > > > > > > > > > Hey Geeks I think question can be solved by many ways . some of the > > algorithms are i have implemented & aware of are -> > > > 1st. Algo > > Generate all palindromes (even & odd length ) of given string while keep > > tracking of their length in last just compare max (evenlength_palindrome , > > oddlength_palindrome) . > > Time Complexity O(N^2) where N is length of String > > > 2nd . Algo. For Those Who are just saying Use DP :) > > Find The LCS(Longest Common Sub-sequence of String (say s1)& reverse of > > String (say s2) ) It Involves > > DP to solve efficiently but guaranteed optimal solution > > Time Complexity O(N^2) where N is length of String > > Space Complexity O(N^2) for table > > > 3rd. Use Suffix Tree ( Need to Work On It) basic idea is to build the > > suffix tree of string & reverse string check no every node where suffix > > belongs to , the deepest common node will us longest palindrome in given > > string. > > > Correct me if i missed something ? > > > Thanks > > Shashank Mani > > Computer Science > > Birla Institute of Technology ,Mesra -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.