Data Structures & AlgorithmsModerateTCS NQT Digital · Infosys

Problem: Consider the graph on vertices 1–6 with edges 1-2, 2-3, 3-4, 4-1, 5-6. What is the size of its largest connected component?

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

Correct answer: A. 4

There are two components, {1,2,3,4} and {5,6}, so the largest has four vertices. The 4-cycle 1-2-3-4 is the component that forms the answer.

More Coding Interview Problems questions

Exams that ask this topic