Data Structures & AlgorithmsModerateGATE CS · Codeforces Div 2 B
A connected undirected graph has the vertices B, D, J, K, Q, X and the edges X–J, X–B, X–D, J–B, J–Q, J–K, J–D, B–K, B–D. Parallel edges are allowed when you add new edges. What is the minimum number of new edges to add so that the graph has an Euler circuit (every vertex has even degree)?
- A. 2
- B. 4
- C. 9
- D. 3
Correct answer: A. 2
Only odd-degree vertices need fixing; pairing them up with new edges takes 2 edges, one per pair. There are 4 odd-degree vertices, so adding one edge per odd vertex wastes half the work.
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
- A connected undirected graph has the vertices A, F, I, M, Q, S, X and the edges M–Q, M–S, M–A, M–X, Q–S, S–F, A–I. How many bridges does…
- Bellman–Ford is run from source C on the directed graph whose arcs (weights in brackets) are listed in the order they are relaxed: C→F…
- A flow network has source S and sink T, with directed arcs and capacities in brackets: S→A (5), S→D (9), S→T (7), E→C (2), E→D (2), E→T…
- An undirected graph has the vertices D, L, N, R, X, Z and the edges N–L, Z–X, X–L, Z–D, L–R, Z–L, Z–N. How many simple cycles does it…
- An undirected graph has the vertices A, J, L, Q, W, X, Y and the edges L–J, L–X, L–W, L–A, Q–X, Q–A, J–Y, Y–W. What is the size of a…
- A pile holds p stones. In one move a player removes exactly s stones, where s is one of {1, 2, 4} and s ≤ the pile size. The player who…