Data Structures & AlgorithmsHardGATE CS · Product-company placement
Kruskal's algorithm runs on the weighted undirected graph A–B (15), A–F (7), A–G (21), B–C (17), B–D (23), B–F (22), D–F (8), E–F (13), E–G (16), F–G (5). Which edge is accepted FOURTH, and what is the MST weight?
- A. A–B, weight 65
- B. E–F, weight 65
- C. E–F, weight 64
- D. D–F, weight 65
Correct answer: B. E–F, weight 65
Edges are taken in increasing weight, skipping any that closes a cycle (rejected: E–G, A–G, B–F…); the accepted edges in order are F–G, A–F, D–F, E–F, A–B, B–C, 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
- A complete binary tree (array form, all levels full except possibly the last, which is filled from the left) has 131 nodes. How many…
- Six sorted files have 10, 12, 13, 21, 23, 42 records. Merging two files of sizes a and b costs a + b. What is the minimum total cost to…
- Five matrices have dimensions 3×2 , 2×4 , 4×2 , 2×8 , 8×10. What is the minimum number of scalar multiplications needed to compute their…
- Keys 17, 35, 21, 81, 58, 30, 62, 57, 82, 93, 61 are inserted in that order into an empty BST. Then 58 is deleted and after that 35 is…
- Using parts 1, 2, 3 (each any number of times), in how many ways can 7 be written as an ORDERED sum (so 1 + 2 and 2 + 1 count separately)?
- For the string ABRACADABRA, what are the lengths of the longest palindromic SUBSTRING and the longest palindromic SUBSEQUENCE?