Data Structures & AlgorithmsVery hardICPC regional · GATE CS
Simple undirected graph on vertices 0 to 4 with edges: 0–1, 1–4, 1–3, 3–4, 2–3, 0–4, 0–2, 0–3. How many simple cycles does it contain? A cycle has at least 3 distinct vertices and is counted once however it is traversed.
- A. 4
- B. 5
- C. 12
- D. 24
Correct answer: C. 12
Enumerating each cycle from its smallest vertex gives 12 simple cycles. The cycle rank (4) counts independent cycles only, the triangles (5) are a subset, and doubling for direction is a slip.
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
- Simple undirected graph on vertices 0 to 4 with edges: 0–2, 0–3, 0–4, 3–4, 1–4, 2–3, 0–1, 1–3. How many simple cycles does it contain? A…
- Simple undirected graph on vertices 0 to 6 with edges: 0–5, 2–3, 2–6, 5–6, 0–3, 0–2, 0–4, 4–5, 1–2. How many simple cycles does it…
- Simple undirected graph on vertices 0 to 6 with edges: 2–3, 2–4, 0–6, 4–6, 2–5, 0–5, 4–5. How many simple cycles does it contain? A cycle…
- Simple undirected graph on vertices 0 to 4 with edges: 0–2, 0–4, 0–3, 3–4, 0–1, 1–3, 1–4. How many simple cycles does it contain? A cycle…
- Simple undirected graph on vertices 0 to 4 with edges: 2–3, 1–3, 0–2, 0–3, 1–4, 0–4, 0–1, 3–4. How many simple cycles does it contain? A…
- Undirected weighted graph on letters A to G with edges: E–F (34), E–G (31), A–G (25), B–G (14), D–E (11), A–F (17), C–G (35), F–G (21)…