Question
Download Solution PDFWhich of the following algorithms solves the single-source shortest paths?
Answer (Detailed Solution Below)
Detailed Solution
Download Solution PDFConcept:
Single source shortest path problem finds the shortest path from a source node to all other nodes in a graph.
Explanation:
Dijkstra’s algorithm is used to solve the single source shortest path problem.
Key points for this:
- It is used for both directed and undirected graphs.
- All edges must have non - negative weights.
- Graph must be connected
Algorithm of dijkstra’s algorithm is:
1) dis[s] <- 0 / distance to source node is 0
2) for all vertices v except source vertex
3) do dist[v] -> infinity
4) s -> empty / initially there are no visited nodes, set is empty
5) while Q <- v / queue contains all nodes
6) while Q is not empty
7) do u -> mindistance (Q, dist) / select node from queue having minimum distance
8) S-> S U {node} / add that selected node to the set (list of visited nodes)
9) for all vertices that are neighbours of node
10) do if dist[v] > dist[node] + w(u, v)
11) then d[v] -> d[node] + w[u,v] / new value for shortest path is set
12) return distLast updated on Jun 6, 2025
-> The UGC NET Exam Schedule 2025 for June has been released on its official website.
-> The UGC NET Application Correction Window 2025 is available from 14th May to 15th May 2025.
-> The UGC NET 2025 online application form submission closed on 12th May 2025.
-> The June 2025 Exam will be conducted from 21st June to 30th June 2025
-> The UGC-NET exam takes place for 85 subjects, to determine the eligibility for 'Junior Research Fellowship’ and ‘Assistant Professor’ posts, as well as for PhD. admissions.
-> The exam is conducted bi-annually - in June and December cycles.
-> The exam comprises two papers - Paper I and Paper II. Paper I consists of 50 questions and Paper II consists of 100 questions.
-> The candidates who are preparing for the exam can check the UGC NET Previous Year Papers and UGC NET Test Series to boost their preparations.