Data Structures & AlgorithmsVery hardGATE CS · ICPC regional · Product Company SDE
An undirected graph has edges (u–v: weight) A–B:10, A–C:12, A–D:4, D–E:29, D–F:26, D–B:13. What is the weight of its minimum spanning tree?
- A. 81
- B. 65
- C. 78
- D. 82
Correct answer: A. 81
Kruskal: sort edges and add the cheapest that does not form a cycle: AD(4), AB(10), AC(12), DF(26), DE(29) → 81. Simply taking the 5 lightest edges may create a cycle.
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
- In the undirected graph with edges A–B:8, B–C:6, A–D:3, D–E:1, C–F:2, E–F:1, F–A:4, what is the shortest-path distance from A to D?
- Keys 63, 44, 55, 66, 68, 84, 93, 50, 52, 76 are inserted in this order into an empty BST. What is the height of the tree (edges on the…
- An undirected graph has edges (u–v: weight) A–B:13, A–C:16, A–D:20, C–E:2, B–F:18, D–F:10, D–B:23. What is the weight of its minimum…
- In the undirected graph with edges A–B:10, A–C:12, C–D:3, D–E:8, E–F:2, E–A:9, what is the shortest-path distance from A to D?
- A complete binary tree has 87 nodes. How many leaves does it have?
- Keys 87, 32, 67, 97, 11, 60, 23, 69, 21 are inserted in this order into an empty BST. How many nodes lie in the left subtree of the root 87?