Data Structures & AlgorithmsVery hardGATE CS · ICPC regional
A connected undirected graph has the vertices B, M, R, T, U and the edges U–T, U–M, U–R, T–R, T–B, M–B, R–B. 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. 4
- B. 7
- C. 3
- D. 2
Correct answer: D. 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
- An undirected graph has the vertices A, D, F, P, U, Y and the edges P–A, Y–A, D–A, D–U, Y–F, D–F, P–F, U–A, Y–D, F–U. What is the minimum…
- A directed acyclic graph has the vertices D, L, P, Q, R, U, V and the edges V→R, Q→R, U→R, U→Q, U→D, U→P, L→Q. A topological order lists…
- Consider this recursive function: python def f(n): if n <= 0: return f(n - 2) if n % 3 == 0: f(n - 2) How many times is f called in total…
- A counter starts at 1. Each step, you may add 1, add 2, or double the counter. Each step must stay at or below 22. Two sequences of steps…
- Starting from the integer 9, one operation either adds 1, subtracts 1, or doubles the current value. Values may be any non-negative…
- An undirected graph has the vertices A, O, S, T, V, Y and the edges Y–V, T–A, T–V, O–T, O–A, Y–A, S–V, O–S, V–A. What is the minimum…