In BFS, what is the initial distance (d[v]) assigned to all vertices except…
2025
In BFS, what is the initial distance (d[v]) assigned to all vertices except the source?
- A.
0
- B.
1
- C.
-1
- D.
infinity
Attempted by 146 students.
Show answer & explanation
Correct answer: D
In Breadth-First Search, the source vertex is initialized with a distance of zero. All other vertices are assigned infinity to indicate they have not yet been discovered or reached.