Home »
MCQs »
Algorithms MCQs
In BFS, what condition indicates the presence of a cycle in an undirected graph?
18. In BFS, what condition indicates the presence of a cycle in an undirected graph?
- If a node is visited twice during traversal.
- If the graph is connected.
- If the graph has more edges than vertices.
- If a node has no adjacent nodes.
Answer
The correct answer is: A) If a node is visited twice during traversal.
Explanation
In an undirected graph, if BFS encounters a node that has already been visited (and it is not the immediate parent node), it indicates the presence of a cycle.