Bellman-Ford
Algorithm
Shortest Path with Negative
Weights
Presented By
Sabrina Hasem (59)
Md Abu Bakkar Siddiq (62) 1
Presented to
Faria Sultana Bintha Rohman
Lab Technical Officer (LTO)
Department of CSE
Feni University
2
Introduction
• The Bellman-Ford Algorithm finds the shortest paths
from a single source to all other vertices in a weighted
graph.
• Unlike Dijkstra’s algorithm, it works with negative
weights.
• It also detects negative weight cycles.
3
How It Works
• Initialization: dist[source] = 0, others = ∞
• Repeat |V|-1 times:
Relax all edges:
if dist[u] + w < dist[v]: dist[v] = dist[u] + w
• Cycle Check: One more pass — if still updates, negative
cycle exists.
4
Pseudocode
5
Time and Space
Complexity
• Time Complexity: O(V * E)
• Space Complexity: O(V)
• Suitable for sparse graphs.
6
Bellman-Ford vs Dijkstra
Feature Bellman-Ford Dijkstra
Negative Weights Yes No
Cycle Detection Yes NO
Time Complexity O(VE) O(V log V + E)
7
Conclusion
• Bellman-Ford is a powerful algorithm for:
⚬ Handling negative weights
⚬ Detecting negative weight cycles
⚬ Solving single-source shortest path
problems
8
Q&A
"Thank you! We'd be happy to
answer any questions."
9
Thank
You
10

Bellman Fords Algorithm Presentation.pptx