Question 1 - BFS

Consider the following statements about detecting cycles using BFS:

I. In an undirected graph, a cycle can be detected if BFS discovers an already visited node that is not the parent of the current node.

II. In a directed graph, a cycle can be detected during BFS by encountering a node that is currently in the queue (i.e., discovered but not fully processed).

III. BFS cannot be used for cycle detection in either directed or undirected graphs.

IV. When used to test bipartiteness, BFS indirectly detects cycles of odd length if they exist.

V. BFS can always detect cycles in a weighted graph, regardless of whether the weights are positive or negative.

Which of the statements are correct?

A) I and II

B) I, II and IV

C) III and V

D) Only IV

E) None of the above

Original idea by: Jhonatan Cléto

Comentários

Postar um comentário

Postagens mais visitadas deste blog

Question 3 - Calculus & Network Flow

Question 2 - Directed Graphs and SCCs