Data Structures & AlgorithmsHardGATE CS · Product-company placement
Kruskal's algorithm runs on the weighted undirected graph A–B (20), A–C (3), A–E (8), A–F (6), B–D (10), C–D (1), C–G (16), D–E (25), D–F (9), D–G (23). Which edge is accepted FOURTH, and what is the MST weight?
- A. B–D, weight 44
- B. A–E, weight 37
- C. A–F, weight 44
- D. A–E, weight 44
Correct answer: D. A–E, weight 44
Edges are taken in increasing weight, skipping any that closes a cycle (rejected: D–F, A–B, D–G…); the accepted edges in order are C–D, A–C, A–F, A–E, B–D, C–G, total 44.
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
- A binary search tree holds exactly the keys 16, 17, 41, 44, 69, 81, 82, 95. Which ONE of the following sequences can be its PREORDER…
- In the DAG with edges A→D, A→F, C→B, D→B, D→C, D→E, D→F, D→G, E→B, G→E, G→F, how many distinct directed paths are there from A to F, and…
- An undirected graph has edges A–B, A–G, B–E, C–E, C–F, C–G, D–E, D–F, D–G. An ITERATIVE DFS starts with stack [A]; it pops a vertex, skips…
- What is the length of the shortest string that has BOTH COMPUTER and SUBSEQUENT as subsequences (shortest common supersequence)?
- A rooted tree has 6 nodes with 1 child, 6 nodes with 2 children, 3 nodes with 3 children, and every other node is a leaf. How many leaves…
- Edit distance between HEAPSORT and DYNAMIC where insert and delete cost 1 each but a substitution costs 2: what is the minimum total cost?