Data Structures & AlgorithmsModerateCodeforces Div 2 B · GATE CS
Connected simple undirected graph on vertices 0 to 7 with edges: 1–6, 2–3, 0–6, 0–3, 1–7, 1–4, 0–5, 0–2, 1–3, 0–1, 2–5. What is the minimum number of new edges (each joins two distinct vertices; parallel edges allowed) that must be added so the graph has an Euler trail (a walk that uses every edge exactly once; start and end may differ)?
- A. 3
- B. 6
- C. 4
- D. 2
Correct answer: D. 2
Only odd-degree vertices obstruct a trail, and a trail may have two of them. With 6 odd vertices, each new edge fixes two of them, so (k−2)/2 = 2 new edges are needed. The Euler circuit version would need 3.
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
- Directed weighted graph on vertices 0 to 5 with edges (u→v (w)): 5→0 (5), 1→4 (7), 0→1 (5), 2→1 (1), 2→5 (9), 2→0 (2), 5→2 (1), 0→3 (9)…
- Directed weighted graph on vertices 0 to 4 with edges (u→v (w)): 0→3 (7), 2→4 (1), 1→4 (5), 3→2 (5), 4→0 (3), 1→2 (8). Compute the sum of…
- Directed weighted graph on vertices 0 to 3 with edges (u→v (w)): 2→1 (2), 0→1 (7), 1→2 (5), 1→3 (1), 1→0 (5). Compute the sum of the…
- Directed weighted graph on vertices 0 to 4 with edges (u→v (w)): 2→3 (2), 0→3 (1), 0→4 (4), 0→2 (2), 3→1 (5), 2→0 (5), 3→0 (9), 4→2 (9)…
- Directed weighted graph on vertices 0 to 3 with edges (u→v (w)): 3→0 (5), 2→1 (8), 2→0 (8), 0→1 (9). Compute the sum of the shortest-path…
- Directed weighted graph on vertices 0 to 5 with edges (u→v (w)): 2→1 (3), 3→0 (3), 1→2 (1), 0→4 (5), 0→2 (3), 1→0 (5), 2→3 (7), 0→1 (3)…