Dsa Project (Royce CR)
Dsa Project (Royce CR)
NO: 10
DATE: 8/5/2025
Chapter 1: Abstract
Chapter 2: Introduction
Chapter 3: Methodologies
Chapter 6: Conclusion
Chapter 7: References
Problems
Chapter 1: Abstract
Shortest path algorithms are foundational tools in computer science, especially
in the realm of data structures and algorithms. These algorithms help determine
the most efficient way to navigate between nodes in a network—be it a map, a
computer network, or a decision-making system. This abstract provides an
overview of four key algorithms—Warshall’s, Floyd’s, Dijkstra’s, and Bellman-
Ford—based on three distinct graph problems.
Warshall’s and Floyd’s Algorithms are both used for finding shortest paths
between all pairs of nodes in a directed graph. Warshall’s algorithm focuses on
reachability—essentially whether a path exists between two vertices—by
progressively updating the transitive closure of the graph. Floyd’s algorithm,
however, goes a step further by calculating the shortest path lengths between all
pairs, making it more suitable for weighted graphs like the one in the first
image, where each edge has a cost. Floyd’s algorithm systematically updates
path lengths using a dynamic programming approach and is capable of handling
graphs with positive weights efficiently.
Dijkstra’s Algorithm, which appears in the second part of the first problem, is
a greedy algorithm that finds the shortest path from a single source node to all
other nodes. It continuously selects the node with the smallest tentative distance
and updates its neighbours. It is best suited for graphs with non-negative edge
weights, as seen in the first graph image. This algorithm is intuitive and
efficient, making it popular for real-time applications like GPS routing and
network flow analysis.
Bellman-Ford Algorithm, shown in the final problem with the third graph,
offers an alternative that can handle negative edge weights—something
Dijkstra’s cannot. While slower than Dijkstra’s, Bellman-Ford is robust; it
iteratively relaxes all edges and can detect negative-weight cycles. The graph
used here includes both negative and positive weights, making it ideal for
showcasing Bellman-Ford’s capability to solve complex pathfinding problems
that involve potential cost reductions (e.g., discounts or penalties in economic
models).
4. Performance Observation:
Execution steps and complexity are observed for each algorithm. Warshall’s
and Floyd’s have time complexity of O(n³), making them suitable for dense
graphs. Dijkstra’s runs in O(n²) with an adjacency matrix (or O((V+E) log V)
with a min-priority queue), and Bellman-Ford has O(VE) complexity but
handles negative weights, making it uniquely versatile.
Chapter 4: Comparison of Methodologies
1. Approach and Objective:
4. Limitations:
1. Floyd-Warshall Algorithm:
Floyd-Warshall performed well on dense graphs, accurately calculating
the shortest paths between all pairs of vertices. With a time complexity of
O(n³), it is suitable for smaller graphs but becomes inefficient for larger
ones. However, it cannot detect negative weight cycles, which limits its
applicability in certain scenarios.
2. Dijkstra’s Algorithm:
Dijkstra’s algorithm was efficient on graphs with non-negative edge
weights, with performance improving on sparse graphs when using an
adjacency list and priority queue (O((V + E) log V)). However, it failed
to handle negative edge weights, producing incorrect results in such
cases.
3. Bellman-Ford Algorithm:
Bellman-Ford excelled in handling graphs with negative edge weights
and detecting negative weight cycles. While slower than Dijkstra’s
(O(VE)), it provided essential functionality for graphs involving negative
weights. It was able to compute correct shortest paths and detect negative
cycles, which neither Floyd-Warshall nor Dijkstra’s could do.
Comparative Analysis: