0
0
DSA Typescriptprogramming~5 mins

Connected Components Using BFS in DSA Typescript - 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 through edges.
Click to reveal answer
beginner
How does BFS help in finding connected components?
BFS explores all nodes reachable from a starting node, marking them as visited. This helps identify one connected component at a time.
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
intermediate
In BFS for connected components, what do you do when you find an unvisited node?
Start a BFS from that node to find and mark all nodes in its connected component.
Click to reveal answer
intermediate
Why do we need to check all nodes in the graph when finding connected components?
Because the graph may have multiple disconnected parts, and BFS from one node only finds one connected component.
Click to reveal answer
What does BFS use to keep track of nodes to visit next?
AQueue
BStack
CSet
DArray
What is the main goal of BFS when finding connected components?
ATo visit all nodes in one connected component
BTo find cycles
CTo sort nodes
DTo find shortest path between two nodes
If a graph has 3 connected components, how many BFS runs are needed to find them all?
A1
B2
C3
DDepends on graph size
What do you do when BFS finishes exploring one connected component?
AStop the algorithm
BStart BFS from another unvisited node
CRemove edges
DSort the nodes
Which graph type is suitable for connected components using BFS?
ADirected graph only
BBoth directed and undirected graphs
CWeighted graph only
DUndirected graph only
Explain step-by-step how BFS is used to find connected components in an undirected graph.
Think about visiting nodes layer by layer and marking them.
You got /5 concepts.
    Describe why BFS alone from one node does not find all connected components in a graph.
    Consider what happens if the graph has isolated groups.
    You got /4 concepts.