@atul..

R u trying. to find the longest even palindrome or just an even
palindrome ?

If ur looking for the longest even palindrome then it be bbbb and the
size returned would be 4.

If ur looking for just an even palindrome and want break out as per my
comments given then it will be "bb" and size would be 2.

I just traced it and it looks fine..

Also looking at ur example and assuming that ur just trying to find an
even palindrome and longest one then i see that the breaking out of
the loop is correct and the size is 2 with the string being "bb"..

Hence, can u be more specific...



On 30 Dec, 21:10, Lucifer <[email protected]> wrote:
> @atul,
> I don't have a break condition..
> Can u be more specific..
>
> On 30 Dec, 21:07, atul anand <[email protected]> wrote:
>
>
>
>
>
>
>
> > @Lucifier :
>
> > your 1st approach fails for the following cases:-
>
> > *aaaa*
> > *aa*bb*aa*
> > *aaa*gg*aaa*
>
> > etc....
>
> > basically for cases where the 1st two and last two character of the even
> > palindrome are same.
>
> > for eg:-
>
> > 1 2 3 4
> > ----------
> > b b b b
>
> > 1st iteration :-
>
> > X = 1 1 1 1
>
> > 2nd iteration :-
>
> > X= 1 1 1 2
>
> >  (pStrt - X[pStrt] + 1 == pRev) -> *3=4-2+1* this condition will satisfy
> > and loop will break.
>
> > On Fri, Dec 30, 2011 at 9:02 PM, atul anand <[email protected]> wrote:
> > > @praveen : question is to find longest even length pallindrome.
>
> > > there was some misunderstanding earlier.
>
> > > so if input is aaaa
> > > output string is = aaaa
>
> > > check lucifier post above.
>
> > > we discussed another question in the same post bcoz
> > > of initial misunderstanding :-
>
> > > Q) Given a string of length N, find whether there exits an even length
> > >  reverse substring of a substring.
>
> > > you can see mine or lucifier algo for this question.
>
> > > On Fri, Dec 30, 2011 at 8:23 PM, praveen raj <[email protected]>wrote:
>
> > >> The Question is: whther there exist a even length pallindrome or not....
>
> > >> since for even ... the two consecutive character will be equal...
>
> > >> so find two character which are equal.. consecutively......
>
> > >> PRAVEEN RAJ
> > >> DELHI COLLEGE OF ENGINEERING
>
> > >>  --
> > >> You received this message because you are subscribed to the Google Groups
> > >> "Algorithm Geeks" group.
> > >> To post to this group, send email to [email protected].
> > >> To unsubscribe from this group, send email to
> > >> [email protected].
> > >> For more options, visit this group at
> > >>http://groups.google.com/group/algogeeks?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to