Recursion with Return instruction without parameter
Please I have a doubt about following code:
public void solveTowers( int disks, int sourcePeg, int destinationPeg,
int tempPeg )
{
if ( disks == 1 )
{
System.out.printf( "\n%d --> %d", sourcePeg, destinationPeg );
return;
}
solveTowers( disks - 1, sourcePeg, tempPeg, destinationPeg );
System.out.printf( "\n%d --> %d", sourcePeg, destinationPeg );
}
--
If I enter witch amount variable DISK = 3
I'd like to known: Why ouput after perform the code is
1>3
2>3
1>3?
I didn't get it about the mechanism logical of RETURN instruction !!!
Please, some could me help and explain about with mechanism
OBS: An draw or design it will be helpfull for me understant
A lot of thanks
Gmourad

