The BFS procedure is as follows. BFS(G, s) 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: for each vertex u E G.V- {s} do u.color = WHITE u.d = ∞ U.TT = NIL s.color= GRAY s.d = 0 S.TT = NIL Q = 0 Enqueue(Q, s) while Q <> do u =Dequeue(Q) for each v G.adj[u] do if v.color == WHITE then v.color= GRAY v.d = u.d + 1 V.TT = U Enqueue(Q, v) u.color = BLACK Do you think we can remove the line 18: u.color Explain why. BLACK from the algorithm?
The BFS procedure is as follows. BFS(G, s) 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: for each vertex u E G.V- {s} do u.color = WHITE u.d = ∞ U.TT = NIL s.color= GRAY s.d = 0 S.TT = NIL Q = 0 Enqueue(Q, s) while Q <> do u =Dequeue(Q) for each v G.adj[u] do if v.color == WHITE then v.color= GRAY v.d = u.d + 1 V.TT = U Enqueue(Q, v) u.color = BLACK Do you think we can remove the line 18: u.color Explain why. BLACK from the algorithm?
Related questions
Question
100%
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps