Data Structures & AlgorithmsModerateICPC regional · GATE CS top band

Undirected graph on vertices A, B, C, D, E, F, G with weighted edges A–B (6), A–G (9), B–C (6), B–G (8), C–D (6), C–F (1), D–G (8), E–F (1), E–G (2), F–G (1). Keep only the edges of weight at most 6 (discard the others). How many connected components does the remaining graph have?

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

Correct answer: C. 1

Only edges of weight ≤ 6 survive; the result has 1 components. Subtracting the number of kept edges from n ignores the edges that close cycles and gives 0.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic