sir please explain me this portion of code
soln [i][j]=0;
if( right_success || left_success)
return true;
return false;
does not that mean if there were more than one solution
so the condition will be right after it finds the first one ,and it will return right to the main function and we will not be able to find other solutions…
Rate in a maze recursion
Hello @mzk1994 in this when we are returning the true and false this means that we are just finding whether even only a single path to the end block exist or not.
when we have returned true that means “Yes” there is any atleat single path which can lead us to the end.
If you have any other doubt you can ask here:
Happy Learning!!
sir thanks a lot for you, I do understand the logic if it was for one path only…my problem is after finding the first path and we reach till (n-,m-1)
how the program can generate other unique paths using backtracking?
Hello @mzk1994 this you can do so when you are in the base case i.e when you are printing the solution which we have got then you can do this by retrurning false there because when we will return false then it means that we havent got the solution and we want to find the check if there is any solution further available as well.
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.