Data Structures & AlgorithmsHardICPC regional · GATE CS top band
Directed graph on vertices A, B, C, D, E, F with edges D→E, A→B, C→D, F→E, F→C, E→D, A→D, C→A. How many strongly connected components does it have? Count each vertex's component, including single vertices that have no cycle through them.
- A. 5
- B. 1
- C. 2
- D. 4
Correct answer: A. 5
Mutual-reachability classes give 5 strongly connected components; weakly connected components ignore direction and give 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
- Undirected simple graph on vertices A, B, C, D, E, F with edges A–C (1), B–D (1), B–E (1), B–F (1), C–D (1), C–E (1), C–F (1), D–E (1)…
- Directed acyclic graph on vertices A, B, C, D, E, F, G (edges go from earlier to later letters) with weights A→B (3), A→D (4), A→E (4)…
- Points A(1,7), B(2,4), C(4,9), D(8,8), E(2,7) in the plane. The cost of joining two points is the Manhattan distance |x1−x2| + |y1−y2|…
- An undirected graph has the vertices G, Q, R, U, Y, Z and the edges Q–Z, Y–Q, G–Z, R–Z, G–R, Y–R. How many simple cycles does it contain…
- A directed acyclic graph has the vertices F, H, J, K, L, N, R and the arcs H→J, H→R, H→N, K→J, K→F, K→N, L→R, L→F, J→R, J→F, J→N, R→F. Two…
- A directed acyclic graph has the vertices B, H, K, O, W and the arcs K→B, K→W, K→O, B→H, B→O, W→O. Two players alternately move a single…