Postagens

Mostrando postagens de agosto, 2025

Question 1 - BFS

Consider the following five statements regarding the Breadth-First Search (BFS) algorithm: I. For any given unweighted graph, the length of the shortest path found by BFS between two nodes is always less than or equal to the length of the path found by a Depth-First Search (DFS) between the same two nodes.  II. A single execution of BFS starting from an arbitrary node s is sufficient to identify all connected components in any given undirected graph.  III. An undirected graph can be tested for its bipartiteness by running BFS from a source node ' s'  and ensuring that every edge connects two vertices that lie in layers of opposite parity (one at an even distance from  s , the other at an odd distance). IV. The BFS algorithm can be implemented using a stack data structure instead of a queue and will still fulfill its function of finding the shortest path in unweighted graphs.  Which statements are correct?  a) II and IV b) I and III ...