Re: [algogeeks] ReVerse a string using recursion

2010-09-23 Thread uday kumar
void RevStr (char *str){
char ch = '\0';
if (*str){
ch = *str;
RevStr (++str);
}
printf ("%c", ch);
}

On Fri, Sep 24, 2010 at 12:37 AM, Nishant Agarwal <
nishant.agarwa...@gmail.com> wrote:

>
> @Albert
> i think this should be right
>
> static int i=0;
> int j;
> void xstrrev(char *s)
> {
> char t;
> if(i==0)
> j=strlen(s)-1;
>
> if(i {
> t=s[i];
> s[i++]=s[j];
> s[j--]=t;
> xstrrev(s);
>
> }
> }
> On Fri, Sep 24, 2010 at 12:05 AM, albert theboss 
> wrote:
>
>> Ur function prototype is not similar to one i posted before
>>
>> check it out
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@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.
>>
>
>
>
> --
>  :-)
> *
> Nishant Agarwal
> Computer Science and Engineering
> NIT Allahabad
> *
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@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 algoge...@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] ReVerse a string using recursion

2010-09-23 Thread Nishant Agarwal
@Albert
i think this should be right

static int i=0;
int j;
void xstrrev(char *s)
{
char t;
if(i==0)
j=strlen(s)-1;
if(iwrote:

> Ur function prototype is not similar to one i posted before
>
> check it out
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@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.
>



-- 
 :-)
*
Nishant Agarwal
Computer Science and Engineering
NIT Allahabad
*

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@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] ReVerse a string using recursion

2010-09-23 Thread coolfrog$
*...@nisanth : help me plz... to solve this
finding largest and second largest elements from a set of n elements by
means of
  Minimum comparison of  n+celling(log n) +2*

On Thu, Sep 23, 2010 at 1:50 PM, Nishant Agarwal <
nishant.agarwa...@gmail.com> wrote:

> i am giving the full code
>
> #include
> #include
> #include
>
> void xstrrev(char *s , int i , int j)
> {
> char t;
> if(i {
> t=s[i];
> s[i]=s[j];
> s[j]=t;
> xstrrev(s,i+1,j-1);
> }
> }
> int main()
> {
> char *s;
> s=(char *)malloc(sizeof(s));
> gets(s);
> xstrrev(s,0,strlen(s)-1);
> puts(s);
> return 0;
> }
>
>
> On Fri, Sep 24, 2010 at 12:15 AM, coolfrog$ <
> dixit.coolfrog.div...@gmail.com> wrote:
>
>> @nishant:
>> what is i and j..???
>> @
>>
>> On Thu, Sep 23, 2010 at 1:20 PM, Nishant Agarwal <
>> nishant.agarwa...@gmail.com> wrote:
>>
>>> void xstrrev(char *s , int i , int j)
>>> {
>>> char t;
>>> if(i>> {
>>> t=s[i];
>>> s[i]=s[j];
>>> s[j]=t;
>>> xstrrev(s,i+1,j-1);
>>>
>>> }
>>> }
>>>
>>> On Thu, Sep 23, 2010 at 11:29 PM, Albert wrote:
>>>
 How to reverse a String using recursion in C without using any extra
 memory?

 the question seems to be simple.

 char* strrev(char *)
 {
...
...
...
 }


 Try to give all the answers for this prototype.

 --
 You received this message because you are subscribed to the Google
 Groups "Algorithm Geeks" group.
 To post to this group, send email to algoge...@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.


>>>
>>>
>>> --
>>>  :-)
>>> *
>>> Nishant Agarwal
>>> Computer Science and Engineering
>>> NIT Allahabad
>>> *
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algoge...@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 algoge...@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.
>>
>
>
>
> --
>  :-)
> *
> Nishant Agarwal
> Computer Science and Engineering
> NIT Allahabad
> *
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@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 algoge...@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] ReVerse a string using recursion

2010-09-23 Thread Nishant Agarwal
i am giving the full code

#include
#include
#include
void xstrrev(char *s , int i , int j)
{
char t;
if(i wrote:

> @nishant:
> what is i and j..???
> @
>
> On Thu, Sep 23, 2010 at 1:20 PM, Nishant Agarwal <
> nishant.agarwa...@gmail.com> wrote:
>
>> void xstrrev(char *s , int i , int j)
>> {
>> char t;
>> if(i> {
>> t=s[i];
>> s[i]=s[j];
>> s[j]=t;
>> xstrrev(s,i+1,j-1);
>>
>> }
>> }
>>
>> On Thu, Sep 23, 2010 at 11:29 PM, Albert  wrote:
>>
>>> How to reverse a String using recursion in C without using any extra
>>> memory?
>>>
>>> the question seems to be simple.
>>>
>>> char* strrev(char *)
>>> {
>>>...
>>>...
>>>...
>>> }
>>>
>>>
>>> Try to give all the answers for this prototype.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algoge...@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.
>>>
>>>
>>
>>
>> --
>>  :-)
>> *
>> Nishant Agarwal
>> Computer Science and Engineering
>> NIT Allahabad
>> *
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@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 algoge...@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.
>



-- 
 :-)
*
Nishant Agarwal
Computer Science and Engineering
NIT Allahabad
*

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@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] ReVerse a string using recursion

2010-09-23 Thread coolfrog$
@nishant:
what is i and j..???
@

On Thu, Sep 23, 2010 at 1:20 PM, Nishant Agarwal <
nishant.agarwa...@gmail.com> wrote:

> void xstrrev(char *s , int i , int j)
> {
> char t;
> if(i {
> t=s[i];
> s[i]=s[j];
> s[j]=t;
> xstrrev(s,i+1,j-1);
>
> }
> }
>
> On Thu, Sep 23, 2010 at 11:29 PM, Albert  wrote:
>
>> How to reverse a String using recursion in C without using any extra
>> memory?
>>
>> the question seems to be simple.
>>
>> char* strrev(char *)
>> {
>>...
>>...
>>...
>> }
>>
>>
>> Try to give all the answers for this prototype.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@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.
>>
>>
>
>
> --
>  :-)
> *
> Nishant Agarwal
> Computer Science and Engineering
> NIT Allahabad
> *
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@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 algoge...@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] ReVerse a string using recursion

2010-09-23 Thread albert theboss
Ur function prototype is not similar to one i posted before

check it out

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@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] ReVerse a string using recursion

2010-09-23 Thread Nishant Agarwal
void xstrrev(char *s , int i , int j)
{
char t;
if(i wrote:

> How to reverse a String using recursion in C without using any extra
> memory?
>
> the question seems to be simple.
>
> char* strrev(char *)
> {
>...
>...
>...
> }
>
>
> Try to give all the answers for this prototype.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@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.
>
>


-- 
 :-)
*
Nishant Agarwal
Computer Science and Engineering
NIT Allahabad
*

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@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] ReVerse a string using recursion

2010-09-23 Thread coolfrog$
Sorry ...correction we have to bring temp2 to last char again... so

char* temp, temp2;
char* s="Nitin";
for(temp2=s;*temp2='\0';temp2++ );/*just to calculate the length of s*/
--temp2; *<===*
  void strrev(char * s,char* temp2)
{  if (s==temp2 ||s>temp2)
  {return;}
*temp = *s;
  *s=* temp2;
 *temp2=*temp;
 temp2++;
 s++;
 strrev(*s,*temp2)

}
On Thu, Sep 23, 2010 at 1:15 PM, coolfrog$
wrote:

> char* temp, temp2;
> char* s="Nitin";
> for(temp2=s;*temp2='\0';temp2++ );/*just to calculate the length of s*/
>
>   void strrev(char * s,char* temp2)
> {  if (s==temp2 ||s>temp2)
>   {return;}
> *temp = *s;
>   *s=* temp2;
>  *temp2=*temp;
>  temp2++;
>  s++;
>  strrev(*s,*temp2)
>
> }
>
> But it is using two extra char pointer... is that allowed.??
>
>
> On Thu, Sep 23, 2010 at 12:59 PM, Albert  wrote:
>
>> How to reverse a String using recursion in C without using any extra
>> memory?
>>
>> the question seems to be simple.
>>
>> char* strrev(char *)
>> {
>>...
>>...
>>...
>> }
>>
>>
>> Try to give all the answers for this prototype.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@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 algoge...@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] ReVerse a string using recursion

2010-09-23 Thread coolfrog$
char* temp, temp2;
char* s="Nitin";
for(temp2=s;*temp2='\0';temp2++ );/*just to calculate the length of s*/

  void strrev(char * s,char* temp2)
{  if (s==temp2 ||s>temp2)
  {return;}
*temp = *s;
  *s=* temp2;
 *temp2=*temp;
 temp2++;
 s++;
 strrev(*s,*temp2)

}

But it is using two extra char pointer... is that allowed.??

On Thu, Sep 23, 2010 at 12:59 PM, Albert  wrote:

> How to reverse a String using recursion in C without using any extra
> memory?
>
> the question seems to be simple.
>
> char* strrev(char *)
> {
>...
>...
>...
> }
>
>
> Try to give all the answers for this prototype.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@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 algoge...@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.



[algogeeks] ReVerse a string using recursion

2010-09-23 Thread Albert
How to reverse a String using recursion in C without using any extra
memory?

the question seems to be simple.

char* strrev(char *)
{
...
...
...
}


Try to give all the answers for this prototype.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@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.