Data Structures & AlgorithmsHardProduct company OA

An undirected graph has edges 1–2, 2–3, 3–1, 3–4, 4–5, 5–6, 6–4, 6–7, 7–8. How many BRIDGES (edges whose removal disconnects the graph) does it have?

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

Correct answer: D. 3

Edges on a cycle are never bridges: the triangles 1-2-3 and 4-5-6 are safe. 3–4 joins the two triangles, 6–7 and 7–8 lead to a dead-end path – each of these three disconnects something when removed. Counting only 3–4 and 6–7 (forgetting the last edge to a leaf) gives 2.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic