What is the primary purpose of the 'visited' array in Dijkstra's algorithm?

Practice Questions

1 question
Q1
What is the primary purpose of the 'visited' array in Dijkstra's algorithm?
  1. To store the shortest path from the source to each vertex.
  2. To keep track of which vertices have been processed.
  3. To hold the distances from the source to each vertex.
  4. To maintain the priority queue.

Questions & Step-by-step Solutions

1 item
Q
Q: What is the primary purpose of the 'visited' array in Dijkstra's algorithm?
Solution: The 'visited' array in Dijkstra's algorithm is used to keep track of which vertices have been processed to avoid reprocessing them.
Steps: 6

Related Questions

Soulshift Feedback ×

On a scale of 0–10, how likely are you to recommend The Soulshift Academy?

Not likely Very likely