![]() |
| ||
| how to reverse link list using recurtion please can someone give me code how to reverse single link list using recurtion thanks |
| ||
| Re: how to reverse link list using recurtion Quote:
|
| ||
| Re: how to reverse link list using recurtion Quote:
Ohhh I am new to the forum and I was not knowing the rules :mrgreen: :p That I have to show attempt ... Here is what I was trying to do ! :evil: :evil: Without Recurtion :-) struct node *p,*q,*r; With recurtion : list *tail;<< moderator edit: added [code][/code] tags >> In general can we reverse link list using REFERERCNCE to pointer as function parameter .... :idea: |
| ||
| Re: how to reverse link list using recurtion You're on the right track. Try incorporating a temporary link into your function rather than trying to work just with head and its next links. |
| ||
| Re: how to reverse link list using recurtion Quote:
temparary variable are temparary to scope of function and in recursive function we use global variable sort of things :rolleyes: In general we can use static pointer but then toomit does not workk CAN ANYONE HELP ME ITS URGENT :cry: :cry: |
| ||
| Re: how to reverse link list using recurtion >> Temperary variable to be passed in recursive function No. >> temparary variable are temparary to scope of function Yea. >> and in recursive function we use global variable sort of things What are you babbling about? It's possible and perfectly reasonable to use a non-static local variable in a recursive function. This function doesn't need a static variable or a global variable. Here's your current function: list *reverse (list *head)Here's my modification using a local temporary: link *reverse_list(link *head)The algorithm is identical, but my function is completely self-contained and works properly whereas yours would have unnecessary coupling with that global variable if you kept following the same line of thinking. |
| ||
| Re: how to reverse link list using recurtion Ohhh thanks .....Its finally working .. |
| All times are GMT -4. The time now is 9:48 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC