Data Structures & AlgorithmsModerateCodeforces Div 2 D · ICPC regional
An undirected graph has the vertices G, Q, R, U, Y, Z and the edges Q–Z, Y–Q, G–Z, R–Z, G–R, Y–R. 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. 4
- C. 1
- D. 0
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 = 1 counts independent cycles, which is not the same count, and there are 1 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 directed acyclic graph has the vertices F, H, J, K, L, N, R and the arcs H→J, H→R, H→N, K→J, K→F, K→N, L→R, L→F, J→R, J→F, J→N, R→F. Two…
- A directed acyclic graph has the vertices B, H, K, O, W and the arcs K→B, K→W, K→O, B→H, B→O, W→O. Two players alternately move a single…
- On an 6×6 chessboard, rows and columns are numbered 0 to 5, and squares are written (row, column). A knight moves in the usual L-shape…
- A connected undirected graph has the vertices E, F, J, K, L, W, Y, Z and the edges Y–E, Y–W, E–Z, E–L, E–W, E–J, Z–L, Z–F, W–K. Parallel…
- A flow network has source S and sink T, with directed arcs and capacities in brackets: S→C (7), B→E (5), D→B (7), D→C (2), C→B (9), C→E…
- Consider this function: python def g(n): if n < 2: return n if n % 2 == 0: return g(n - 3) + g(n - 3) return g(n - 3) - 1 What value does…