Which of the following algorithms solves the single-source shortest paths?

This question was previously asked in
UGC NET Computer Science (Paper 2) July 2018 Paper
View all UGC NET Papers >
  1. Prim’s algorithm
  2. Floyd - Warshall algorithm
  3. Johnson’s algorithm
  4. Dijkstra’s algorithm

Answer (Detailed Solution Below)

Option 4 : Dijkstra’s algorithm
Free
UGC NET Paper 1: Held on 21st August 2024 Shift 1
10.8 K Users
50 Questions 100 Marks 60 Mins

Detailed Solution

Download Solution PDF

Concept:

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 dist
Latest UGC NET Updates

Last 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.

More Graphs/Spanning Tree and Shortest Paths Questions

Get Free Access Now
Hot Links: teen patti real cash 2024 teen patti classic teen patti apk teen patti game - 3patti poker