Data Structures & AlgorithmsHardGATE CS · ICPC regional
Connected undirected graph on vertices A, B, C, D, E, F, G, H with edges A–F (1), A–G (1), B–C (1), B–E (1), C–E (1), D–E (1), E–H (1), F–H (1) (weights ignored). How many bridges does it have? A bridge is an edge whose removal disconnects the graph.
- A. 4
- B. 2
- C. 1
- D. 5
Correct answer: D. 5
Removing each edge in turn and testing connectivity gives 5 bridges. Articulation points or the cyclomatic number are different structural counts that a student may mix up.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- Array A = [11, 19, 21, 15, 20] (all values below 32). What is the maximum of A[i] XOR A[j] over all index pairs with 0 ≤ i < j < 5?
- Undirected simple graph on vertices A, B, C, D, E, F, G with edges A–B (1), A–C (1), A–D (1), A–E (1), C–E (1), C–F (1), C–G (1), D–F (1)…
- A chain of 5 matrices M1 to M5 has dimensions given by the sequence p = [11, 8, 3, 12, 16, 9], where Mi has size p[i−1] × p[i]…
- Undirected graph on vertices A, B, C, D, E, F with weighted edges A–B (4), A–C (7), A–E (3), B–C (6), B–E (4), B–F (2), C–D (7), C–F (2)…
- Undirected weighted graph on vertices A, B, C, D, E with edges A–D (1), B–D (2), B–E (1), C–D (1), C–E (2), D–E (3). An edge is CRITICAL…
- Strings a = "accabb" and b = "aaab". The edit distance allows insert, delete and substitute, each costing 1 (the standard Levenshtein…