Data Structures & AlgorithmsModerateGATE CS
A simple undirected graph has 13 vertices and exactly 4 connected components. What is the maximum possible number of edges?
- A. 36
- B. 74
- C. 42
- D. 45
Correct answer: D. 45
Put 3 isolated vertices aside and make the remaining 10 vertices a complete graph: C(10, 2) = 45. 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
- What is the length of the shortest string that has BOTH COMPILER and SHORTEST as subsequences (shortest common supersequence)?
- Prim's algorithm starts at G on the weighted undirected graph A–B (19), A–F (12), A–G (21), B–C (13), B–D (23), B–E (6), B–G (29), D–E…
- The weighted undirected graph A–B (1), A–C (6), A–D (3), A–E (4), B–C (4), B–D (3), C–D (5) has repeated weights. How many different…
- A simple undirected graph has 9 vertices and exactly 4 connected components. What is the maximum possible number of edges?
- With 3 identical eggs and at most 6 drops, what is the largest number of floors for which you can always determine the critical floor (the…
- A 4 × 4 grid has rows 1 3 8 3 / 7 6 6 2 / 4 9 8 9 / 9 8 4 5. Moving only right or down from the top-left to the bottom-right cell, what is…