Data Structures & AlgorithmsVery hardGATE CS
Dijkstra's algorithm runs from A on the directed graph A→B (4), A→F (8), B→C (1), B→D (10), C→A (3), C→D (8), C→E (6), C→F (6), E→B (1), E→F (10), F→B (1), F→D (6) (relaxations into already-finalised vertices are skipped). How many times is dist[D] lowered (counting the first change from ∞), and what is its final value?
- A. 3 times, final 13
- B. 1 time, final 13
- C. 2 times, final 14
- D. 2 times, final 13
Correct answer: D. 2 times, final 13
dist[D] drops only when a newly finalised in-neighbour gives a strictly shorter route; tracing the finalisation order A B C F E D gives 2 decreases ending at 13. It is not simply the in-degree (3).
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
- In the DAG with edges A→E, A→G, B→E, C→A, C→B, C→E, C→F, C→G, D→F, E→F, G→F, how many distinct directed paths are there from C to F, and…
- For the string PROPERTY, what are the lengths of the longest palindromic SUBSTRING and the longest palindromic SUBSEQUENCE?
- DFS runs on the directed graph with adjacency lists A: D; B: CF; C: AEG; D: –; E: ABG; F: D; G: F, starting at A, scanning lists in the…
- Symbols occur with frequencies 24, 26, 33, 34, 35, 38. How many bits does an optimal (Huffman) prefix code need for the whole message, and…
- A binary search tree holds exactly the keys 27, 34, 63, 64, 72, 73, 95, 99. Which ONE of the following can be its POSTORDER traversal?
- Five matrices have dimensions 5×5 , 5×5 , 5×15 , 15×4 , 4×3. What is the minimum number of scalar multiplications needed to compute their…