Data Structures & AlgorithmsModerateTCS NQT · Accenture pattern

An undirected graph has 6 vertices with degrees 3, 3, 2, 2, 2 and x, and it has 8 edges. What is x?

  1. A. 2
  2. B. 6
  3. C. 3
  4. D. 4

Correct answer: D. 4

Handshake lemma: the degrees add up to 2E = 16. The known degrees sum to 12, so x = 4. Using E instead of 2E (8 − 12) gives a negative number, a sign that the factor 2 was forgotten.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic