Data Structures & AlgorithmsHardICPC regional · GATE CS top band
Directed graph on vertices A, B, C, D, E, F, G with edges C→F, F→G, F→E, A→D, E→C, C→G, B→F, A→G, B→C, G→C, A→E. How many strongly connected components does it have? Count each vertex's component, including single vertices that have no cycle through them.
- A. 3
- B. 2
- C. 4
- D. 1
Correct answer: C. 4
Mutual-reachability classes give 4 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
- On an 7 × 7 chessboard with rows and columns numbered 0 to 6, a knight starts at (0, 0) and must reach (5, 1) (as (row, column)). A knight…
- A trie keeps a counter at each node, and every word of the list W = ['ab', 'acc', 'aac', 'bcaa', 'cab', 'ab', 'a'] is inserted once per…
- Array A = [22, 11, 12, 9, 20, 23, 25, 15, 2]. How many index pairs i < j satisfy (A[i] XOR A[j]) < 21? (A trie with subtree counts answers…
- Array A = [17, 0, 16, 23, 30, 19, 8, 11, 10]. How many index pairs i < j satisfy (A[i] XOR A[j]) < 13? (A trie with subtree counts answers…
- Points A(6,3), B(8,7), C(3,7), D(9,2), E(3,6), F(0,4) in the plane. The cost of joining two points is the Manhattan distance |x1−x2| +…
- Undirected simple graph on vertices A, B, C, D, E, F, G with edges A–B (1), A–D (1), B–D (1), B–E (1), B–G (1), C–D (1), C–F (1), D–E (1)…