Data Structures & AlgorithmsHardCodeforces Div 2 C · GATE CS
An undirected graph has the vertices D, L, N, R, X, Z and the edges N–L, Z–X, X–L, Z–D, L–R, Z–L, Z–N. How many simple cycles does it contain (a cycle visits distinct vertices and returns to its start; cycles that use the same edge set are the same cycle)?
- A. 3
- B. 1
- C. 4
- D. 2
Correct answer: A. 3
Enumerate edge subsets in which every vertex has degree 0 or 2 and the edges form one connected cycle: there are 3. The cyclomatic number m − n + 1 = 2 counts independent cycles, which is not the same count, and there are 2 triangles.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- An undirected graph has the vertices A, J, L, Q, W, X, Y and the edges L–J, L–X, L–W, L–A, Q–X, Q–A, J–Y, Y–W. What is the size of a…
- A pile holds p stones. In one move a player removes exactly s stones, where s is one of {1, 2, 4} and s ≤ the pile size. The player who…
- An undirected graph has the vertices F, J, K, M, S, T, V, X and the edges J–V, J–X, J–F, J–M, J–K, V–F, V–S, X–F, X–M, X–K, F–K, S–M. What…
- An undirected graph has the vertices A, J, K, L, O, Q, X, Y and the edges J–Q, J–Y, J–A, J–O, Q–L, Q–X, K–L, K–O. What is the size of a…
- An undirected graph has the vertices C, E, H, K, M, N, T, Y and the edges E–M, E–N, E–Y, E–T, C–N, C–H, C–Y, C–T, M–N, M–K, N–K, Y–T. What…
- An undirected graph has the vertices C, F, J, O, U, V, W, X, Z and the edges Z–O, Z–U, Z–C, F–U, F–J, O–J, O–V, O–W, U–W, U–X, U–C, V–W…