Consider the following diagram (not in scale): There are seven places marked as P, Q, R, S, T, U and V as shown in the diagram. The directly connected paths between two places are indicated by line segments joining the two places along with the length labelled in km. Then, the shortest distance between P and U is:
Consider the following diagram (not in scale): There are seven places marked as P, Q, R, S, T, U and V as shown in the diagram. The directly connected paths between two places are indicated by line segments joining the two places along with the length labelled in km. Then, the shortest distance between P and U is: Correct Answer 12 km
Dijkstra Algorithm(Shortest Path Algorithm) - For a given source node in the graph, the algorithm finds the shortest path between that node and every other. It can also be used for finding the shortest paths from a single node to a single destination node by stopping the algorithm once the shortest path to the destination node has been determined.
For these type of question to get shortest distance need to start with starting point and choose the nearest point with minimum distance. Again from that particular point choose the point with minimum distance and this process will go one till the destination point.
So here the path with minimum distance is as follows:
[ alt="F1 5f53b11706d3e73d959ac90e Resham.R 01-10-20 Savita Dia" src="//storage.googleapis.com/tb-img/production/20/10/F1_5f53b11706d3e73d959ac90e_Resham.R_01-10-20_Savita_Dia.png" style="width: 234px; height: 153px;">
P → Q → R→ S →T→ V → U
Shortest distance from P to U = 4 + 2 + 1 + 3 + 1 + 1 = 12 Km
Hence, "12 Km" is the correct answer.