Bellman Ford and One Olympiad Questions?

后端 未结 2 1764
梦如初夏
梦如初夏 2021-02-19 09:01

I took an Olympiad Exam three days ago. I ran into a nice question as follows.

We know the bellman-ford algorithm checks all edges in each step, and for each edge if,

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-19 09:39

    i think option 3 is incorrect because to know if there is negative weight cycle ,the Bellman ford algorithm needs to run n times. first n-1 times to calculate the shortest path and then one more time to check if there is any improvement in the distances if there are improvements ,it means there is a negative weight cycle.

提交回复
热议问题