Data Structures & AlgorithmsModerateCodeforces Div 2 C · GATE CS
A connected undirected graph has the vertices A, D, E, F, H, J, M, Z and the edges J–Z, J–D, J–F, J–M, Z–F, Z–H, Z–E, D–A, D–F, A–E, F–E. 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. 3
- B. 2
- C. 11
- D. 4
Correct answer: B. 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
- On an 8×8 chessboard, rows and columns are numbered 0 to 7, and squares are written (row, column). A knight moves in the usual L-shape…
- An undirected graph has the vertices C, D, E, L, M, S, U and the edges U–E, U–S, U–C, D–L, D–C, D–M, L–S, L–M, E–S, E–M, C–M. What is the…
- An undirected graph has the vertices D, E, H, M, O, P, U, V and the edges H–O, H–M, H–D, H–V, O–E, O–V, O–P, M–U, M–V, E–D, E–U, D–U, D–V…
- An undirected connected graph on the vertices B, H, O, P, S has the edges H–S, O–B, S–P, H–P, S–B, B–P, H–B. How many spanning trees does…
- A tree has vertices A, C, G, J, N, Q, X, Y and weighted edges (weights in brackets): Y–Q (2), Y–X (5), Y–J (2), J–C (2), C–A (8), X–G (7)…
- Two unmarked jugs hold 5 litres and 7 litres. Allowed operations: fill a jug completely, empty a jug completely, or pour one jug into the…