Suppose if we have 3 point 1,2,3;
d(1,2) = 10;
d(1,3) = 20;
d(2,3) = 500;
then shortest path sequence should be 1->2->1->3->1 (60)
Can we pass traverse an edge more than 1 time
In this problem it is preferred that each node is visited just once. If we go by your suggestion we will encounter any of the 2 cases:
1)Either the code will end up in endless recursion leading to TLE
2) If we set the mask condition as the base case of solution it will be reached before actual condition is met.
Therefore path traversal with repetitive visiting of paths is not viable.
I hope this was helpful to you.
Thank You
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.