Data Structures & AlgorithmsModerateGATE CS
A simple undirected graph has 14 vertices and exactly 2 connected components. What is the maximum possible number of edges?
- A. 66
- B. 89
- C. 77
- D. 78
Correct answer: D. 78
Put 1 isolated vertices aside and make the remaining 13 vertices a complete graph: C(13, 2) = 78. Splitting vertices more evenly across components always gives fewer edges.
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
- How many structurally different binary trees with 7 nodes have height EXACTLY 5 (height = edges on the longest root-to-leaf path)?
- Keys 72, 29, 21, 18, 28, 16, 23, 33, 25, 67 are inserted in order into an empty AVL tree. Counting a double rotation as two single…
- DFS runs on the directed graph with adjacency lists A: BG; B: FG; C: AEFG; D: C; E: A; F: A; G: –, starting at A, scanning lists in the…
- A tree on vertices 1–8 has edges 2–1, 3–2, 4–2, 5–2, 6–2, 7–4, 8–3. What is the sum of the distances (in edges) over all unordered pairs…
- The weighted undirected graph A–B (1), A–C (3), A–D (5), B–D (3), B–E (6), C–D (3), D–E (6) has repeated weights. How many different…
- A DAG on vertices A–G has edges A→C, A→D, A→E, E→B, E→C, E→F, G→E, G→F. What order does Kahn's algorithm that always removes the…