Data Structures & AlgorithmsVery hardICPC regional · Product Company SDE
Problem: A graph on vertices 0–6 has edges 0-1, 0-2, 1-3, 2-3, 3-4, 4-5, 5-6, 4-6. Count the bridges (edges whose removal increases the number of connected components).
- A. 2
- B. 0
- C. 3
- D. 1
Correct answer: D. 1
An edge is a bridge exactly when it lies on no cycle. Edges inside the 4-cycle 0-1-3-2 and the triangle 4-5-6 are not bridges, so only the connecting edge qualifies.
More Coding Interview Problems questions
- Problem: Maximum bipartite matching is computed for left side {A, B, C, D} and right side {1, 2, 3, 4} with allowed pairs: A–1, A–2, B–2…
- Problem: A tree has 8 nodes numbered 1–8 with edges 1-2, 1-3, 2-4, 2-5, 3-6, 3-7, 7-8. What is the size of a minimum vertex cover (a…
- Problem: In the directed graph on vertices 1–6 with arcs 1→2, 1→3, 2→4, 3→4, 4→5, 3→6, 6→5, what is the length of the longest directed…
- Problem: A binary tree is given in preorder (root first, then left subtree, then right subtree) as 8, 3, 1, 6, 4, 7, 10, 14, 13 and…
- Problem: For the binary tree with root value 2 and children: 2 has left child 3 and right child 9; 3 has left child 1 and right child 5; 9…
- Problem: The string "banana" has its longest repeated substring (a substring occurring at least twice, overlaps allowed) of length L. What…