Wrong answer in Bellman Ford Algorithm
@tushaartiwari1997
@ mistakes
- Dont initialise to INT_MAX use 10000 instead
when you add anything to INT_MAX it overflows and becomes negative - Your adjlist does not have those nodes through which no edge starts
For eg : C in our case. So v is 4 while it should be 5
So how to modify my list
@tushaartiwari1997
When you take input, put both nodes in a set.
At the end the number of elements in the set will the be the number of vertices in graph
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.