← Graphs Quiz: all 8 questions
Graphs Quiz · Question 8 of 8
In BFS, when should a node be marked visited to avoid adding it to the queue many times?
In BFS, when should a node be marked visited to avoid adding it to the queue many times?
- A.When it is pushed onto the queue
- B.When it is popped from the queue
- C.After the whole BFS finishes
- D.It never needs marking
Answer & explanation
Correct answer: When it is pushed onto the queue
Marking on push ensures each node is enqueued once.
Can you get the rest right without peeking?
Take the timed Graphs Quiz quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →