Data Structures & AlgorithmsVery hardCodeforces Div 2 D · ICPC regional
A connected undirected graph has the vertices A, E, G, J, P, Q, Z and the edges Z–P, Z–J, Z–E, Z–A, P–J, P–G, J–E, A–Q. How many bridges does it have (edges whose removal disconnects the graph)?
- A. 4
- B. 2
- C. 5
- D. 3
Correct answer: D. 3
Removing each edge in turn and testing connectivity finds 3 bridges. The cyclomatic number m − n + 1 = 2 counts independent cycles, not bridges; there are 3 articulation vertices, and 2 vertices of degree 1.
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 A, B, J, Q, Y and the edges Q–J, Q–B, Y–J, Y–B, A–J. A walk may repeat vertices and edges. How many…
- Consider this recursive function: python def f(n): if n <= 1: return f(n - 1) if n % 2 == 0: f(n - 3) How many times is f called in total…
- A counter starts at 1. Each step, you may add 1, add 2, or double the counter. Each step must stay at or below 24. Two sequences of steps…
- Floyd–Warshall runs on vertices 1 to 4 with these arcs u→v (weight): 1→4 (4), 2→1 (1), 2→3 (4), 3→1 (5), 3→4 (10), 4→1 (6), 4→2 (6), 4→3…
- A counter starts at 1. Each step, you may add 1, add 2, or double the counter. Each step must stay at or below 17. Two sequences of steps…
- A grid has 8 rows and 5 columns (rows listed top to bottom; '.' is an open cell, '#' a wall): .#.## ..... #...# .#... ..... ..##. ....#…