Data Structures & AlgorithmsVery hardGATE CS · ICPC regional
An undirected graph has the vertices C, E, F, L, U, X, Z and the edges L–C, C–U, X–L, E–C, Z–L, E–U, F–L, Z–C, E–Z, X–U. 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. 4
- B. 13
- C. 3
- D. 14
Correct answer: B. 13
Enumerate edge subsets in which every vertex has degree 0 or 2 and the edges form one connected cycle: there are 13. The cyclomatic number m − n + 1 = 4 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
- An undirected graph has the vertices F, I, M, Q, T and the edges I–Q, Q–M, I–F, Q–F, I–T, T–Q, T–M, I–M, T–F. What is the minimum number…
- 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…
- An undirected connected graph on the vertices H, K, L, V has the edges L–K, V–H, H–K, V–K, L–H, V–L. How many spanning trees does it have?…
- A directed acyclic graph has the vertices A, E, G, V, X, Z and the edges G→E, G→V, X→G, X→A, A→Z, Z→E. A topological order lists every…
- A tree has the vertices A, F, I, O, P, U, Y and the edges I–A, I–F, F–U, U–O, F–P, P–Y. What is the minimum number of vertices needed so…
- A tree has vertices with values in brackets: U[-2], B[7], H[5], A[7], N[-2], P[5], C[4], S[-1]. The edges are U–B, U–H, H–A, A–N, B–P…