About the shortest distance to node 3

will the shortest distance to node 3 be -1 or the distance has to be positive and equal to 4,it’s direct distance from the source?

image

are you taking about this graph??

shortest distance to node 3 from node 1 will be -1

yes in SSSP we always find shortest path from source .

shortest distance can be negative also as all edges may have negative weights

Yes so the shortest distance should always be positive right? Dada pls can you suggest me resources about the time complexity of prims dijkstra and bellman Ford algorithms pls

no it can be negative

time complexity of these algorithms are discussed in the same video
on which you are asking your doubt

So why isn’t the shortest distance of node 3 =-1?

yes the distance from source (1) to node 3 will be -1 via 2

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.