Data Structures & AlgorithmsModerateTCS NQT · Infosys
Problem: An undirected graph on 7 vertices (0–6) has degrees 0:3, 1:2, 2:4, 3:1, 4:2, 5:3, 6:1. How many vertices have odd degree? (Such a graph has an Eulerian circuit only when this number is 0.)
- A. 4
- B. 5
- C. 3
- D. 6
Correct answer: A. 4
By the handshake lemma the number of odd-degree vertices is even, and an Eulerian circuit requires zero of them. The count itself is the quantity asked here, not a yes/no decision.
More Coding Interview Problems questions
- Problem: Vertices 0–5 with undirected edges 0-1, 1-2, 2-0, 2-3, 3-4, 4-5, 5-3. How many articulation points (cut vertices, whose removal…
- Problem: Using a min-heap, the stream 9, 4, 7, 1, 8, 2, 6, 3, 5 is processed as follows: after each insertion, pop the minimum if the heap…
- Problem: For the array [4, 1, 5, 2, 6, 3, 7], compute, for each index i, the distance to the next strictly greater element to its right (0…
- Problem: The maximum of each window of length 3 in [1, 3, −1, −3, 5, 3, 6, 7] is recorded for all windows. What is the sum of these window…
- Problem: Ship packages in order (weights 4, 7, 2, 9, 5, 3, 8, 6, 1) through consecutive days, with each day's load at most a capacity C…
- Problem: Count the triples of indices i < j < k in [2, 5, 1, 7, 3, 4, 6] with a[i] + a[j] + a[k] ≤ 12.