Data Structures & AlgorithmsVery hardICPC regional · Product Company SDE

Problem: Vertices 1–6 of an undirected graph have edges 1-2, 2-3, 4-5, 5-6, 6-4 and 3-1. How many edges are NOT part of any cycle?

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

Correct answer: B. 0

An edge lies on a cycle exactly when removing it does not disconnect its endpoints. Here the two triangles 1-2-3 and 4-5-6 have all their edges on cycles, so the count of edges on no cycle is zero.

More Coding Interview Problems questions

Exams that ask this topic