Data Structures & AlgorithmsVery hardProduct-company placement
A directed graph on A–H has edges A→B, A→C, A→G, B→E, E→G, F→A, F→B, F→C, F→E, H→B, H→D. 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. 8 SCCs, 3 edges
- C. 7 SCCs, 3 edges
- D. 8 SCCs, 2 edges
Correct answer: B. 8 SCCs, 3 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) = 3.
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
- Keys 56, 16, 21, 93, 86, 85, 15 inserted in this order build a BST. How many of the 7! orderings of these same 7 keys, inserted into an…
- A tree on vertices 1–11 has edges 2–1, 3–2, 4–2, 5–3, 6–3, 7–4, 8–6, 9–7, 10–7, 11–8. What is the size of a maximum independent set (no…
- All suffixes of the string 'level' are inserted into a character trie (a suffix trie). How many nodes does it have, including the root?
- A DAG on vertices A–G has edges A→D, A→F, C→D, E→C, F→B, F→D, G→A, G→F. What order does Kahn's algorithm with a FIFO queue (initial zero…
- What is the edit distance (insert, delete, substitute; each cost 1) between DIAMETER and INTERVAL?
- Prim's algorithm starts at F on the weighted undirected graph A–B (18), A–F (15), B–E (26), B–F (23), B–G (21), C–D (9), C–E (16), D–E…