Data Structures & AlgorithmsHardGATE CS · Codeforces Div 2 B
An undirected graph has the vertices K, L, N, P, Q, R and the edges P–K, K–N, R–Q, R–N, N–L, N–Q, K–L, P–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. 5
- C. 2
- D. 4
Correct answer: D. 4
Enumerate edge subsets in which every vertex has degree 0 or 2 and the edges form one connected cycle: there are 4. The cyclomatic number m − n + 1 = 3 counts independent cycles, which is not the same count, and there are 3 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
- A tree has the vertices A, D, E, L, P, V, X and the edges X–D, X–P, X–E, D–V, E–L, P–A. What is the minimum number of vertices needed so…
- An undirected graph on 6 vertices has the edges H–T, H–Y, H–X, T–W, T–F, Y–F, W–F, W–X, F–X. How many simple paths (no repeated vertex) go…
- Each cell of a grid with 5 rows and 3 columns has an arrow: R = right, L = left, U = up, D = down. URU LDU DRL RLD DUU From a cell you may…
- An undirected graph has the vertices B, C, D, E, I, M, R, S, V and the edges S–B, I–M, I–V, R–M, R–D, R–V, R–C, D–C, V–C, E–B, B–C. What…
- An undirected graph has the vertices C, D, K, M, Q, V and the edges Q–D, Q–M, C–D, K–D, K–V, D–M, D–V. What is the size of a maximum…
- Cities F, M, O, R, S are joined by roads with these travel costs: M–O 11, M–S 20, M–R 7, M–F 16, O–S 16, O–R 14, O–F 8, S–R 11, S–F 8, R–F…