Data Structures & AlgorithmsHardGATE CS · Codeforces Div 2 B
An undirected graph has the vertices J, M, N, Q, R, S, W and the edges R–N, M–Q, Q–J, Q–W, M–S, M–R, Q–R, Q–S, M–J, R–S. 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. 13
- B. 3
- C. 5
- D. 12
Correct answer: D. 12
Enumerate edge subsets in which every vertex has degree 0 or 2 and the edges form one connected cycle: there are 12. The cyclomatic number m − n + 1 = 4 counts independent cycles, which is not the same count, and there are 5 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 connected undirected graph has the vertices B, D, I, N, O, P, Z and the edges I–P, I–B, I–Z, I–N, P–N, P–O, B–D, Z–N. How many bridges…
- An undirected connected graph on 6 vertices has the edges (weights in brackets, all distinct): U–O (17), F–O (26), O–P (18), U–V (10), F–P…
- A directed weighted graph has the arcs u→v (weight): X→L (9), X→K (15), L→X (11), L→O (3), L→K (1), L→M (15), O→X (11), O→L (5), O→M (7)…
- The directed acyclic graph has the vertices A, Q, T, V, W, Z and the arcs A→T, Z→Q, A→Q, W→T, Q→T, V→T, Z→V, A→V, V→Q. How many distinct…
- Two unmarked jugs hold 3 litres and 7 litres. Allowed operations: fill a jug completely, empty a jug completely, or pour one jug into the…
- A tree on the vertices E, H, N, U, W, Z has the arcs H→N, N→Z, U→N, U→E, W→Z (each undirected edge is directed as shown). You may reverse…