Data Structures & AlgorithmsVery hardProduct-company placement
A directed graph on A–H has edges A→H, B→D, B→E, B→H, C→H, D→C, E→A, E→F, F→A, F→D, G→H. How many strongly connected components does it have, and what is the minimum number of edges that must be added to make the whole graph strongly connected?
- A. 8 SCCs, 7 edges
- B. 7 SCCs, 2 edges
- C. 8 SCCs, 2 edges
- D. 8 SCCs, 1 edge
Correct answer: C. 8 SCCs, 2 edges
The SCCs are A | B | C | D | E | F | G | H. In the condensation DAG count sources (in-degree 0) and sinks (out-degree 0); the answer is max(sources, sinks) = 2.
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
- Unit-time jobs (deadline, profit): J1 (3, 34), J2 (3, 62), J3 (3, 67), J4 (4, 10), J5 (3, 27), J6 (3, 79), J7 (3, 89). One job runs at a…
- Floyd–Warshall runs on vertices 1–4 with directed edges 1→2 (4), 2→3 (11), 2→4 (11), 3→1 (7), 3→2 (6), 3→4 (8), 4→3 (11). After the…
- An undirected connected graph has edges A–B, A–E, B–G, C–G, D–E, D–G, D–I, E–G, E–I, F–H, H–I. How many articulation points (cut vertices)…
- What is the length of the longest common subsequence of MARTIAN and GRAPHICAL, and how many DISTINCT longest common subsequences (as…
- What is the length of the shortest string that has BOTH PLACEMENT and KNAPSACK as subsequences (shortest common supersequence)?
- Keys 28, 36, 45, 51, 56 are searched with frequencies 2, 3, 8, 7, 8 respectively (only successful searches). The cost of a BST is Σ…