Recursion:
     http://www.rawkam.com/?p=283
<http://www.rawkam.com/?p=283>Tower Of Hanoi:
     http://www.rawkam.com/?p=917
<http://www.rawkam.com/?p=917>     http://www.rawkam.com/?p=941

<http://www.rawkam.com/?p=941>

On Fri, Sep 10, 2010 at 1:11 AM, albert theboss <alberttheb...@gmail.com>wrote:

> Its easy only ....
>
> tower of hanoi consist of three pegs peg A,peg B,peg C.
> which is used as BEG,AUX,END
>
> Let n be 5 for example...
>
> wat u r going to do is
>
> step 1 : move the top n-1 (4) disks from BEG to  AUX...
>              in this case END will be used as auxiliary.
>
> step 2:  move the n th disk from BEG to END .
>             use AUX as auxiliary in this case
>
> step 3: move the  n-1(4) disks from AUX to END that is moved in step 1
>              use BEG as auxiliary in this step
>
>
> Actual code is
>
>      void tower(int n,char beg,char aux,char end)
>     {
>        if(n>0)
>         {
>                   tower(n-1,beg,end,aux);   //  move n-1 disks from beg to
> aux
>                    printf("%c->%c",beg,aux,end);//equivalent to
> tower(1,beg,aux,end)    move 1 disk from beg to end
>                    tower(n-1,aux,beg,end)  //   move disks from aux to end
>         }
>     }
>
>    again that n-1 disks are moved to end which is called recursively.....
>
> Still u have doubt???
>
>  --
> 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<algogeeks%2bunsubscr...@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.

Reply via email to