Data Structures & AlgorithmsHardProduct-company placement
Kruskal's algorithm runs on the weighted undirected graph A–C (17), A–D (12), A–E (22), A–F (4), A–G (8), B–E (18), C–D (24), C–E (19), E–F (6), F–G (27). Which edge is accepted FOURTH, and what is the MST weight?
- A. A–D, weight 65
- B. A–C, weight 65
- C. A–D, weight 66
- D. A–G, weight 65
Correct answer: A. A–D, weight 65
Edges are taken in increasing weight, skipping any that closes a cycle (rejected: C–E, A–E, C–D…); the accepted edges in order are A–F, E–F, A–G, A–D, A–C, B–E, total 65.
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 maximum flow from S to T in the network with directed capacities A→B (14), A→T (4), C→B (4), C→T (15), S→A (6), S→B (7), S→C…
- Heap sort (ascending) is run on [30, 16, 36, 4, 37, 35, 41, 28]: build a max-heap bottom-up, then repeatedly swap the root with the last…
- What is the minimum number of edges m such that EVERY simple undirected graph with 10 vertices and m edges is guaranteed to be connected?
- How many calls of g (including the first) are made when g(6) is evaluated, and what value is returned? c int g(int n) { if (n <= 2) return…
- For the string CHARACTERS, what are the lengths of the longest palindromic SUBSTRING and the longest palindromic SUBSEQUENCE?
- What is the minimum number of edges that must be deleted from the undirected graph with edges A–B, A–C, A–D, A–E, B–D, B–F, C–E, C–F, D–E…