Question

    What is the primary difference between a breadth-first

    search (BFS) and a depth-first search (DFS) in graph traversal?
    A BFS visits nodes in ascending order of their values, while DFS visits nodes in descending order. Correct Answer Incorrect Answer
    B BFS always finds the shortest path, while DFS does not guarantee finding the shortest path. Correct Answer Incorrect Answer
    C BFS uses a stack, while DFS uses a queue. Correct Answer Incorrect Answer
    D BFS cannot be applied to graphs. Correct Answer Incorrect Answer

    Solution

    BFS always finds the shortest path, while DFS does not guarantee finding the shortest path.

    Practice Next

    Relevant for Exams: