Hi, I often have trouble when events have to be counted in recursion. How do I count these steps? let us say if n = 3, there are 7 steps. how do I count it using recursion? Please Help/
Doubt regarding Counting no. of steps in Tower of Hanoi Problem
hi @luvverma2011,
you can count the answers in the if block where you check if you reached your ans
u can use a global variable for that or pass by reference and increment everytime u reach ans
code --> https://ide.codingblocks.com/s/660393 (commented)
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.