What is the primary purpose of the Bellman-Ford algorithm in graph theory?
Think about shortest paths and negative weights.
The Bellman-Ford algorithm is designed to find the shortest paths from a single source to all vertices, and it works correctly even if some edges have negative weights. It can also detect negative weight cycles.
How many times does the Bellman-Ford algorithm relax all edges in the worst case for a graph with V vertices?
Consider how many edges can be in the longest shortest path.
The algorithm relaxes all edges exactly V - 1 times because the longest possible path without cycles between any two vertices has at most V - 1 edges.
After completing the main iterations of the Bellman-Ford algorithm, what does an additional relaxation step that still updates any distance indicate?
Think about what it means if distances can still be improved after V - 1 iterations.
If distances can still be updated after V - 1 iterations, it means there is a cycle with negative total weight reachable from the source, allowing infinite reductions in path cost.
Which of the following statements correctly compares Bellman-Ford and Dijkstra's algorithms?
Consider the edge weight restrictions for each algorithm.
Bellman-Ford works with negative weights and detects negative cycles. Dijkstra's algorithm assumes all edge weights are non-negative and cannot handle negative weights correctly.
Given a graph with V vertices and E edges, what is the time complexity of the Bellman-Ford algorithm and why?
Think about how many times edges are relaxed and how many edges there are.
The Bellman-Ford algorithm performs V - 1 iterations, and in each iteration, it relaxes all E edges, resulting in O(V * E) time complexity.