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?

  1. A.

    0

  2. B.

    1

  3. C.

    -1

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

Explore the full course: Mppsc Assistant Professor