[algogeeks] Re: ReVerse a string using recursion

2010-09-27 Thread ligerdave
any type of replace would need at least one extra memory space. recursion is the worst, depends how you implement recursion. one iteration might depends on another, which depends one other, and so on.. each iteration hold its own stack On Sep 23, 1:59 pm, Albert alberttheb...@gmail.com

[algogeeks] Re: ReVerse a string using recursion

2010-09-25 Thread Krunal Modi
I agree with Nishant. For inplace replacement we need to swap two place for that we need index, which is not possible without additional variables. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] Re: ReVerse a string using recursion

2010-09-25 Thread albert theboss
please let me know solution using extra memory. -- 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

Re: [algogeeks] Re: ReVerse a string using recursion

2010-09-25 Thread Nishant Agarwal
@albert why r u asking for a non optimal solution?? On Sat, Sep 25, 2010 at 11:24 PM, albert theboss alberttheb...@gmail.comwrote: please let me know solution using extra memory. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To

[algogeeks] Re: ReVerse a string using recursion

2010-09-25 Thread Gene
Here is another approach. Remove the first character. Reverse the rest of the string recursively. Append the character at the end. Others have given solutions along these lines, but they have various mistakes. Here's one that I believe is correct. As pointed out already, this is not a good

[algogeeks] Re: ReVerse a string using recursion

2010-09-24 Thread vikas kumar
use it like this char* strrev(char *) strrev(str) void strrev(char *str) { xstrrev(str , 0, strlen(str)); // code posted by Nishant } :-) On Sep 23, 11:35 pm, albert theboss alberttheb...@gmail.com wrote: Ur function prototype is not similar to one i posted before check it

[algogeeks] Re: ReVerse a string using recursion

2010-09-24 Thread Minotauraus
char * strRev(char* string) { static int ptr; if(ptr == lengthOf(string)/2 || ptr == lengthOf(string/2)+1) { return string; } ptr++; strRev(swap(string, ptr-1, lengthOf(string)-ptr-2)); } where swap returns a string with the chars at the two

Re: [algogeeks] Re: ReVerse a string using recursion

2010-09-24 Thread albert theboss
@nishanth : could u give me any solutions without global variable or static variable -- 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

Re: [algogeeks] Re: ReVerse a string using recursion

2010-09-24 Thread Nishant Agarwal
@albert i think you know the solution and u r just testing others.so post the solution and stop this discussion.. On Sat, Sep 25, 2010 at 12:48 AM, albert theboss alberttheb...@gmail.comwrote: @nishanth : could u give me any solutions without global variable or static variable

Re: [algogeeks] Re: ReVerse a string using recursion

2010-09-24 Thread albert theboss
sorry i dont know the solution. i just expecting such answer -- 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

Re: [algogeeks] Re: ReVerse a string using recursion

2010-09-24 Thread Nishant Agarwal
i dont think that without giving 1st and last index, this is possible.i m using i and j as 1st and last index respectively On Sat, Sep 25, 2010 at 1:00 AM, albert theboss alberttheb...@gmail.comwrote: sorry i dont know the solution. i just expecting such answer -- You