Data Structures & AlgorithmsHardGATE CS
Kruskal's algorithm runs on the weighted undirected graph A–D (13), A–F (22), B–F (5), B–G (19), C–D (12), C–G (17), D–F (27), D–G (20), E–F (7), E–G (15). Which edge is accepted FOURTH, and what is the MST weight?
- A. E–G, weight 69
- B. A–D, weight 69
- C. A–D, weight 71
- D. C–D, weight 69
Correct answer: B. A–D, weight 69
Edges are taken in increasing weight, skipping any that closes a cycle (rejected: B–G, D–G, A–F…); the accepted edges in order are B–F, E–F, C–D, A–D, E–G, C–G, total 69.
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 min-heap is stored in a 0-indexed array [4, 15, 11, 32, 56, 47, 48]. Perform, in order: insert 28, insert 38, insert 19…
- A directed graph on A–H has edges A→C, A→D, A→H, B→G, B→H, D→E, E→A, E→B, G→F, H→C, H→E. How many strongly connected components does it…
- How many topological orderings does the DAG on vertices A–F with edges C→A, C→B, C→E, F→B, F→C, F→D have?
- A BST holds integer keys between 1 and 100. Which sequence CANNOT be the sequence of keys examined while searching for 50?
- A directed graph on A–H has edges A→G, A→H, B→D, B→E, B→H, F→A, F→D, F→E, G→B, H→C, H→D. How many strongly connected components does it…
- Symbols occur with frequencies 7, 19, 20, 25, 26, 39. How many bits does an optimal (Huffman) prefix code need for the whole message, and…