Doubt regarding algos

In the bellman ford algo why is the distance vector initialised with n+1 and Int max.

hello @Somasree

total n vertices are there with there vertex number in range [1…n]
and becuase we have vertex number utpo N, size of vector should be atleast N+1(becuase we want to access its index n).

we initialise it with INT_MAX becuase initially we assume all vertex are at very far distance from the source

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.