Data Structures & AlgorithmsVery hardCodeforces Div 2 B · GATE CS
Connected simple undirected graph on vertices 0 to 7 with edges: 4–7, 2–4, 4–5, 2–3, 1–5, 6–7, 5–7, 0–6. 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. 2
- B. 3
- C. 6
- D. 4
Correct answer: A. 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
- Connected simple undirected graph on vertices 0 to 7 with edges: 0–4, 0–3, 2–5, 2–7, 1–4, 2–3, 4–6, 3–7, 4–5, 1–3, 0–1, 0–5, 0–7, 3–4…
- Connected simple undirected graph on vertices 0 to 7 with edges: 0–6, 3–7, 1–5, 2–6, 2–3, 1–4, 0–2, 4–5, 3–6, 3–5, 0–3, 0–4, 1–6. What is…
- Connected simple undirected graph on vertices 0 to 7 with edges: 1–3, 0–4, 0–3, 2–6, 2–3, 2–7, 5–7, 0–6. What is the minimum number of new…
- Connected simple undirected graph on vertices 0 to 6 with edges: 1–5, 2–3, 4–5, 0–4, 1–2, 2–5, 4–6, 1–6, 0–6. What is the minimum number…
- Connected simple undirected graph on vertices 0 to 5 with edges: 1–2, 2–4, 2–5, 0–3, 1–5, 0–4, 2–3, 0–2, 0–1, 0–5, 3–4. What is the…
- Connected simple undirected graph on vertices 0 to 7 with edges: 2–4, 0–2, 1–3, 3–5, 2–5, 4–7, 2–7, 0–4, 6–7, 3–6, 0–6, 1–6, 2–6, 1–7…