CS502 GDB 1 Solution and Discussion
-
Consider that a tourist wants to travel between Karachi and Hunza cities in minimum possible span. The road map available has marked distance between each pair of adjacent cities. The time available to the tourist has limited and he/she require to find the shortest possible route between Karachi and Hunza.
In the given scenario, the possible solution may be adopted from the following set of algorithms.
Bellman ford’s Algorithm Flyod Warshal’s Algorithm Dijkstra's Algorithm Breadth-first-search algorithm
You are required to select the possible and most reasonable algorithm for the given scenario. Support you answer with solid reasons.
-
@zareen said in CS502 GDB 1 Solution and Discussion:
require to find the shortest possible route algorithm
Dijkstra’s algorithm (or Dijkstra’s Shortest Path First algorithm, SPF algorithm) is an algorithm for finding the shortest paths between nodes in a graph, which may represent, for example, road networks. It was conceived by computer scientist Edsger W. Dijkstra in 1956 and published three years later.
ReffDijkstra’s algorithm to find the shortest path between a and b. It picks the unvisited vertex with the low distance, calculates the distance through it to each unvisited neighbor, and updates the neighbor’s distance if smaller. Mark visited (set to red) when done with neighbors.
Dijkstra’s algorithmllustration of Dijkstra’s algorithm finding a path from a start node (lower left, red) to a goal node (upper right, green) in a robot motion planning problem. Open nodes represent the “tentative” set (aka set of “unvisited” nodes). Filled nodes are visited ones, with color representing the distance: the greener, the closer. Nodes in all the different directions are explored uniformly, appearing more-or-less as a circular wavefront as Dijkstra’s algorithm uses a heuristic identically equal to 0.
A demo of Dijkstra’s algorithm based on Euclidean distance. Red lines are the shortest path covering, i.e., connecting u and prev[u]. Blue lines indicate where relaxing happens, i.e., connecting v with a node u in Q, which gives a shorter path from the source to v.