Data Structures & AlgorithmsHardGATE CS · ICPC regional
Connected undirected weighted graph on vertices A, B, C, D, E, F with edges A–B (9), A–C (8), A–D (9), A–E (19), B–D (3), B–E (8), B–F (3), C–D (4), C–F (11). What is the total weight of a maximum spanning tree (a spanning tree with the largest possible total weight)?
- A. 74
- B. 48
- C. 56
- D. 26
Correct answer: C. 56
Kruskal run on edges in decreasing weight gives 56. Running the usual ascending order returns the minimum tree, which is the trap.
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
- Consider the recursive function def f(n): if n < 2: return n; return f(n-1) + f(n-2). Evaluate f(9) and count every invocation of f…
- Undirected weighted graph on vertices A, B, C, D, E with edges A–B (2), A–C (1), A–E (3), B–E (2), C–D (1), C–E (3), D–E (2). An edge is…
- Words ['bbb', 'b', 'aab', 'baa', 'baa', 'cc'] are inserted in this order into an empty trie with one node per character, shared prefixes…
- Consider the recursive function def f(n): if n < 3: return 1; return f(n-1) + f(n-3). Evaluate f(10) and count every invocation of f…
- Directed weighted graph on vertices A, B, C, D, E, F with edges listed in this exact order: E→D (7); B→E (-2); C→A (4); D→B (-3); A→B (3)…
- Array A = [3, 2, 4, 10, 10, 2]. Over all non-empty contiguous subarrays, what is the maximum value of the XOR of the elements in the…