Consider an undirected graph where BFS starts from node A. Which of the following sequences correctly represents a possible BFS traversal order?
BFS explores neighbors level by level, visiting all nodes at the current distance before moving further.
BFS visits nodes in order of their distance from the start node. Option C shows a valid level order traversal. Other options mix nodes from different levels.
Which BFS property allows it to find the shortest path in an unweighted graph?
Think about how BFS visits nodes layer by layer.
BFS explores nodes by their distance from the start node, so the first time it reaches a node, it has found the shortest path to it.
What happens when BFS is applied to a directed graph containing cycles?
Consider what happens if BFS revisits nodes endlessly.
If BFS does not keep track of visited nodes, it can revisit nodes in cycles infinitely. Proper tracking prevents this.
Which statement correctly compares BFS and DFS?
Recall the data structures each algorithm uses and their traversal style.
BFS uses a queue to explore neighbors level by level, useful for shortest paths in unweighted graphs. DFS uses a stack (or recursion) to explore as deep as possible before backtracking.
In a social network graph, BFS is used to find all users within 3 degrees of connection from a given user. What is the main reason BFS is suitable for this task?
Think about how BFS visits nodes based on their distance from the start node.
BFS visits nodes in order of their distance from the start, making it ideal to find all users within a certain number of connections (degrees).