Data Structures & AlgorithmsHardCodeforces Div 2 C · GATE CS
A connected undirected graph has the vertices B, E, G, K, Q, R, S, V and the edges Q–K, K–B, K–G, K–S, G–V, G–R, G–E, S–E, R–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. 9
- B. 2
- C. 4
- D. 3
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
- Grid with 4 rows and 3 columns (top to bottom). A cell marked G is a gate; '.' is a normal cell: .GG G.G .G. ... Each step, which is a…
- A tree has vertices with values in brackets: P[-4], S[4], V[7], U[1], G[-4], D[1]. The edges are P–S, S–V, V–U, S–G, S–D. A path is any…
- A four-wheel combination lock shows four digits 0–9 on wheels that wrap around (9 goes to 0 and 0 goes to 9). One move turns one wheel by…
- A grid has 3 rows and 4 columns with these values (top to bottom): 6389 5169 6136 A path moves between side-adjacent cells (up, down, left…
- A directed acyclic graph has the vertices F, H, M, P, U, W and the arcs H→M, H→W, U→F, F→M, F→P, F→W, M→P, M→W. Two players alternately…
- An undirected graph has the vertices A, D, U, W, Y and the edges U–Y, A–D, A–Y, D–Y, W–Y, U–D, A–W, A–U. How many simple cycles does it…