Monday, May 15, 2006

Recursive Fun

I was browsing through orkut and found community on Recursive Programming, and saw below piece of code .. Its cool ..

node* Reverse(node* ptr)
{
if(ptr->next == NULL)
{
Head = ptr;
return ptr;
}

Reverse(ptr->next)->next = ptr;

return ptr;
}



Did anyone get it :-) ....

2 comments:

Shantanu said...

orkut can be useful in this way also????

Well done arvind in finding something on orkut other than hotties. Tell me abt the community

Prashanth(MSP) said...

hmmm .... its smart way of reversing the list. Stack space would be happy with a non-recursive solution though.