Re: [algogeeks] Re: convert a word into a palindrome with minimum addition of letters to it

2011-09-07 Thread Victor Manuel Grijalva Altamirano
if we can {add,chance,erase} one letter of the word the solution it´s
fine
but if only can add

DP[i][j]=   0   if i==j
   0  if(i+1)==j  && word[i]==word[j]
   1  if(i+1)==j  && word[i]!=word[j]
min(DP[i+1][j],DP[i][j-1])   otherwise

i think that this it´s fine



2011/9/7 Dumanshu 

> @Victor:
>
> Instead of 0 and 1, shouldn't it be like DP[i-1][j-1]  + 0 and DP[i-1]
> [j-1] + 1
>
>
> On Sep 7, 1:10 am, Victor Manuel Grijalva Altamirano
>  wrote:
> > Try with DP, a little modicated of Edit Distance algorithm
> >
> > State i=the begin of the word , j=the end of the word
> >
> > DP[i][j]=   0   if i==j
> >0  if(i+1)==j  && word[i]==word[j]
> >1  if(i+1)==j  && word[i]!=word[j]
> > min(DP[i+1][j]+1,DP[i][j-1]+1)   otherwise
> > If you have any question ask!!!
> > Good luck!!!
> >
> > Victor Manuel Grijalva Altamirano
> > Universidad Tecnologica de La Mixteca
>
> --
> 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.
>
>


-- 
Victor Manuel Grijalva Altamirano
Universidad Tecnologica de La Mixteca

-- 
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.



Re: [algogeeks] Re: convert a word into a palindrome with minimum addition of letters to it

2011-09-06 Thread Victor Manuel Grijalva Altamirano
Try with DP, a little modicated of Edit Distance algorithm

State i=the begin of the word , j=the end of the word

DP[i][j]=   0   if i==j
   0  if(i+1)==j  && word[i]==word[j]
   1  if(i+1)==j  && word[i]!=word[j]
min(DP[i+1][j]+1,DP[i][j-1]+1)   otherwise
If you have any question ask!!!
Good luck!!!




Victor Manuel Grijalva Altamirano
Universidad Tecnologica de La Mixteca

-- 
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.



Re: [algogeeks] Re: convert a word into a palindrome with minimum addition of letters to it

2011-09-06 Thread Shravan Kumar
@Yamini  Please read the subject of this mail

On Tue, Sep 6, 2011 at 7:54 PM, yamini gupta wrote:

> add all the characters present in the string in reversed order to the
> string
>
> On Sep 6, 1:26 pm, surender sanke  wrote:
> > @sukran, string shouldn't be replaced, only addition of characters
> allowed
> >
> > On Tue, Sep 6, 2011 at 1:48 PM, sukran dhawan  >wrote:
> >
> >
> >
> >
> >
> >
> >
> > > my soln works without increasing the string length
> >
> > > just start with first and last character copy last character with first
> > > increment i and decrement j and contibue the procedure
> > > continue the same till u get mid element :)
> >
> > > On Tue, Sep 6, 2011 at 12:56 PM, Atul Modi 
> wrote:
> >
> > >> can u remove letters also?as in the example 1 'o' seems to have
> been
> > >> removed?
> >
> > >> On Tue, Sep 6, 2011 at 12:25 PM, anshu mishra <
> anshumishra6...@gmail.com>wrote:
> >
> > >>>http://www.spoj.pl/problems/AIBOHP/
> >
> > >>> same problem u have asked!!
> > >>>  --
> > >>> 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.
> >
> > >> --
> > >> 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.
> >
> > >  --
> > > 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.
>
> --
> 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.
>
>

-- 
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.



Re: [algogeeks] Re: convert a word into a palindrome with minimum addition of letters to it

2011-09-06 Thread surender sanke
@sukran, string shouldn't be replaced, only addition of characters allowed


On Tue, Sep 6, 2011 at 1:48 PM, sukran dhawan wrote:

> my soln works without increasing the string length
>
> just start with first and last character copy last character with first
> increment i and decrement j and contibue the procedure
> continue the same till u get mid element :)
>
> On Tue, Sep 6, 2011 at 12:56 PM, Atul Modi  wrote:
>
>> can u remove letters also?as in the example 1 'o' seems to have been
>> removed?
>>
>>
>> On Tue, Sep 6, 2011 at 12:25 PM, anshu mishra 
>> wrote:
>>
>>> http://www.spoj.pl/problems/AIBOHP/
>>>
>>> same problem u have asked!!
>>>  --
>>> 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.
>>>
>>
>> --
>> 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.
>>
>
>  --
> 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.
>

-- 
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.



Re: [algogeeks] Re: convert a word into a palindrome with minimum addition of letters to it

2011-09-06 Thread sukran dhawan
my soln works without increasing the string length

just start with first and last character copy last character with first
increment i and decrement j and contibue the procedure
continue the same till u get mid element :)

On Tue, Sep 6, 2011 at 12:56 PM, Atul Modi  wrote:

> can u remove letters also?as in the example 1 'o' seems to have been
> removed?
>
>
> On Tue, Sep 6, 2011 at 12:25 PM, anshu mishra 
> wrote:
>
>> http://www.spoj.pl/problems/AIBOHP/
>>
>> same problem u have asked!!
>>  --
>> 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.
>>
>
> --
> 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.
>

-- 
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.



Re: [algogeeks] Re: convert a word into a palindrome with minimum addition of letters to it

2011-09-06 Thread Atul Modi
can u remove letters also?as in the example 1 'o' seems to have been
removed?


On Tue, Sep 6, 2011 at 12:25 PM, anshu mishra wrote:

> http://www.spoj.pl/problems/AIBOHP/
>
> same problem u have asked!!
>
> --
> 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.
>

-- 
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.



Re: [algogeeks] Re: convert a word into a palindrome with minimum addition of letters to it

2011-09-05 Thread anshu mishra
http://www.spoj.pl/problems/AIBOHP/

same problem u have asked!!

-- 
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.



Re: [algogeeks] Re: convert a word into a palindrome with minimum addition of letters to it

2011-09-05 Thread Pratz mary
int main()
{

char *s="nitan";
int n,i,j,c=0;
char *d;
n=strlen(s)/2;
//printf("%d",n);
for(i=1;i<=n;i++)
{

if(s[n-i]!=s[n+i])
break;
}
d=strcpy(d,s);

for(j=i;j<=n;j++)
{

if(d[n+j]!=d[n-j])
{

c++;
d[n+j]=d[n-j];
}
}

printf("%s   %d",d,c);
}

On 6 September 2011 01:21, Pratz mary  wrote:

> for yahoo shudnt min additions be yahay?
>
>
> On 6 September 2011 00:48, learner  wrote:
>
>> @sandeep Explain Algorithm/logic & Time Complexity ?
>>
>> Thanks
>>
>> --
>> 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.
>>
>>
>
>
> --
> regards Pratima :)
>



-- 
regards Pratima :)

-- 
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.



Re: [algogeeks] Re: convert a word into a palindrome with minimum addition of letters to it

2011-09-05 Thread Pratz mary
for yahoo shudnt min additions be yahay?

On 6 September 2011 00:48, learner  wrote:

> @sandeep Explain Algorithm/logic & Time Complexity ?
>
> Thanks
>
> --
> 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.
>
>


-- 
regards Pratima :)

-- 
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.