Click here to Skip to main content
16,016,623 members

Comments by phil2846 (Top 1 by date)

phil2846 27-Feb-17 10:13am View    
I've been looking at this problem too for school. This is my output from the txt window logging the values of the variables along the way. a is a reference to which method has been called. What I mainly don't understand at this point is how n increments in one of the steps. I'm not entirely following the logic of the recursion calls either.

call n=3 t1=1 t2=2 t3=3 a=1
call n=2 t1=1 t2=3 t3=2 a=1
call n=1 t1=1 t2=2 t3=3 a=1
Move from 1 to 3
call n=1 t1=1 t2=3 t3=2 a=2
Move from 1 to 2
call n=1 t1=3 t2=1 t3=2 a=3
Move from 3 to 2
call n=1 t1=1 t2=2 t3=3 a=2
Move from 1 to 3
call n=2 t1=2 t2=1 t3=3 a=3
call n=1 t1=2 t2=3 t3=1 a=1
Move from 2 to 1
call n=1 t1=2 t2=1 t3=3 a=2
Move from 2 to 3
call n=1 t1=1 t2=2 t3=3 a=3
Move from 1 to 3