Data Structures & AlgorithmsVery hardGATE CS · ICPC regional
A directed graph has the vertices A, D, J, N, P, V and the arcs N→V, N→P, N→A, V→A, D→A, P→A, A→V, A→D, A→J. How many strongly connected components does it have (maximal sets in which every vertex can reach every other)?
- A. 1
- B. 5
- C. 4
- D. 3
Correct answer: C. 4
Mutual reachability splits the vertices into 4 classes, each a strongly connected component (single vertices count too). Weakly connected components give 1, and counting only components with at least two vertices gives 1.
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
- Bellman–Ford is run from source M on the directed graph whose arcs (weights in brackets) are listed in the order they are relaxed: G→D…
- A grid has 5 rows and 6 columns (top to bottom; '.' open, '#' blocked): ...... .##.#. ...... ....#. ...... You may only move right or…
- A tree has the vertices B, D, E, G, J, O, S, W and the edges S–J, J–D, J–B, B–O, S–G, D–W, G–E. A set D dominates the tree if every vertex…
- A four-wheel combination lock shows four digits 0–9 on wheels that wrap around (9 goes to 0 and 0 goes to 9). One move turns one wheel by…
- A tree has the vertices A, D, E, G, I, L, P, V, W and the edges L–G, L–W, W–P, W–A, A–E, P–D, P–I, L–V. A centroid is a vertex whose…
- A directed acyclic graph has the vertices C, G, K, P, W, X, Z and the arcs Z→X, Z→G, Z→K, C→W, C→K, P→X, P→K, X→W, W→K, G→K. Two players…