0
0
DSA Cprogramming~5 mins

Connected Components Using BFS in DSA C - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a connected component in an undirected graph?
A connected component is a group of nodes where each node is reachable from any other node in the same group by following edges.
Click to reveal answer
beginner
How does BFS help in finding connected components?
BFS explores all nodes reachable from a starting node. By running BFS from unvisited nodes, we find all nodes in that connected component.
Click to reveal answer
beginner
What data structure is commonly used to implement BFS?
A queue is used to keep track of nodes to visit next in BFS.
Click to reveal answer
beginner
In BFS for connected components, why do we mark nodes as visited?
Marking nodes as visited prevents revisiting the same node, avoiding infinite loops and repeated work.
Click to reveal answer
intermediate
What is the time complexity of finding connected components using BFS in a graph with V vertices and E edges?
The time complexity is O(V + E) because each vertex and edge is visited at most once during BFS.
Click to reveal answer
What is the first step when using BFS to find connected components?
AMark all nodes as visited
BStart BFS from an unvisited node
CAdd all nodes to the queue
DRemove edges from the graph
Which data structure is essential for BFS traversal?
AHeap
BStack
CQueue
DSet
How do you know when you have found all connected components in a graph?
AWhen BFS runs once
BWhen the queue is empty
CWhen all edges are removed
DWhen all nodes are visited
What happens if you do not mark nodes as visited in BFS?
AYou may visit nodes multiple times causing infinite loops
BBFS will run faster
CThe graph will change
DEdges will be ignored
What is the main goal of BFS in connected components?
ATo explore all nodes in one connected component
BTo sort nodes by value
CTo find the shortest path between two nodes
DTo remove cycles
Explain step-by-step how BFS is used to find all connected components in an undirected graph.
Think about visiting nodes and marking them to avoid repeats.
You got /5 concepts.
    Describe why marking nodes as visited is important in BFS when finding connected components.
    Consider what happens if you visit the same node multiple times.
    You got /4 concepts.