Rat in Maze problem

I go through the video content and able to understand the problem but when i am dry run the code trying to visualize the in stack frame and recursion all meshup, can you work through the code and how can i visualize in recurrence tree and stack free.?

Hello @Vikaspal,

Do you want me to correct your code? I didn’t understand the last statement of your doubt.:sweat_smile:

To visualize the recursive codes:
I would suggest two points:

  1. Create a stack and keep pushing the function calls inside the stack one above another and for each return statement, pop it out of the stack.

  2. Do not take a large example as it would take too long and might confuse you.
    Thus, rather take a small example where the total recursive calls will be less.

This, way you would be able to understand the concept.

Hope, this would help.

@S18ML0016 thanks I will take of that… the last question is that when I take the big example it will become so confusing or and one more thing is that while dry run the code what should i consider first the recurrence tree or stack memor for recursion problem.

Hello @Vikaspal,

It’s completely depends upon you.
You can choose any one of the two to visualize recursion.

@S18ML0016 thank bro

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.

@Vikaspal
The doubt was reopened.
Is your doubt resolved?

@pratyush63 nope i am facing issue

@pratyush63 in video prateek bhaiya is reducding the grid by m,n-1 and m-1,n according to the conditions it not working for me i am just manipulating the rowandcol index …

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.