Data Structures & AlgorithmsModerateTCS NQT · Infosys

Problem: Starting with 8 singleton sets {0}..{7}, perform these unions in order: (0,1), (2,3), (1,3), (4,5), (6,7), (5,7), (3,4). After all unions, what is the size of the largest set?

  1. A. 4
  2. B. 8
  3. C. 1
  4. D. 7

Correct answer: B. 8

The first six unions build {0, 1, 2, 3} and {4, 5, 6, 7}; the final union (3, 4) joins them into one set of size 8. Stopping before the last union gives 4, reporting the number of sets gives 1, and 7 counts union operations.

More Coding Interview Problems questions

Exams that ask this topic