What is the running time of Bellmann Ford Algorithm?

Nguyễn Pháp

New member
What is the running time of Bellmann Ford Algorithm?
A. O(V)
B. O(V$^{2}$)
C. O(ElogV)
D. O(VE)
 
Answer: d
Explanation: Bellmann Ford algorithm runs in time O(VE), since the initialization takes O(V) for each of V-1 passes and the for loop in the algorithm takes O(E) time. Hence the total time taken by the algorithm is O(VE).
 

Tìm kiếm

Back
Top