Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
2.0k views
in Computer by (69.2k points)

Describe the Dijkstra’s algorithm for finding a shortest path in a given graph. 

1 Answer

+1 vote
by (69.8k points)
selected by
 
Best answer

Let G = (v,e) be a simple graph. Let a & z be any two vertices of the graph. Suppose L(x) denotes the label of the vertex z which represents the length of the shortest path from the vertex a to the vertex z. Wij denotes the weight of the edge eig = (Vi , Vj)

1. let P = Q where p is the set of those vertices which have permanent labels & T = {all vertices of the graph G} 

Set L (a) = 0, L (x) = ∞for all x €T & x≠a

2. Select the vertex v in T which has the smallest label. This label is called the permanent label of v.

Also set P = P U {v} and T = T-{v} 

if v=z then L (z) is the length of the shortest path from the vertex a to z and stop. 

3. If v ≠z then revise the labels of vertices of T i.e. the vertices which do not have permanent labels. The new label of a vertex x in T is given by L (x) = min{old L(x),L(v)+w(y,x)} 

where w (v,x) is the weight of the edge joining the vertex v & x

If there is no direct edge joining v & x then take w(v,x) = ∞

4. Repeat steps 2 and 3 until z gets the permanent label. 

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...