Data Structures & AlgorithmsHardGATE CS · ICPC regional
Directed graph on vertices A, B, C, D, E, F with edges F→C, B→A, C→F, D→B, B→F, A→E, E→F, A→C, B→D (no weights). What is the number of vertices in its largest strongly connected component (maximal set where every vertex can reach every other)?
- A. 2
- B. 6
- C. 1
- D. 4
Correct answer: A. 2
Mutual reachability gives components of sizes whose maximum is 2. Using weakly connected components instead would ignore edge directions and give 6.
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 = [3, 4, 4, 1, 1, 4, 5, 5]. An increasing subsequence is chosen by INDEX positions i1 < i2 < … with A[i1] < A[i2] < … (strictly…
- Directed graph on vertices A, B, C, D, E, F, G with edges E→B, D→A, C→A, B→E, C→B, F→A, E→D, G→B, B→F, F→G. How many strongly connected…
- Keys [20, 43, 1, 35, 37, 18, 49] are inserted, in this order, into an empty AVL tree using the standard rebalancing (left, right…
- On an 7 × 7 chessboard with rows and columns numbered 0 to 6, a knight starts at (4, 5) and must reach (6, 1) (as (row, column)). A knight…
- Distinct words ['c', 'bcb', 'cccb', 'ba', 'bcba', 'bb', 'ac'] are inserted into an empty trie (one node per character, shared prefixes…
- Consider the recursive function def f(n): if n < 3: return 1; return f(n-1) + f(n-3). Evaluate f(8) and count every invocation of f…