Data Structures & AlgorithmsVery hardProduct-company placement
Dijkstra's algorithm runs from A on the directed graph A→D (15), B→A (1), B→C (13), B→F (10), C→D (6), C→F (11), D→B (2), D→E (14), D→F (13), E→A (11), E→B (7), F→A (2) (relaxations into already-finalised vertices are skipped). How many times is dist[F] lowered (counting the first change from ∞), and what is its final value?
- A. 3 times, final 27
- B. 2 times, final 27
- C. 1 time, final 27
- D. 2 times, final 28
Correct answer: B. 2 times, final 27
dist[F] drops only when a newly finalised in-neighbour gives a strictly shorter route; tracing the finalisation order A D B F E C gives 2 decreases ending at 27. 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
- The POSTORDER traversal of a BST with distinct keys is 17, 16, 34, 44, 51, 66, 59, 85, 93, 46. What are the height of the tree (edges on…
- A rooted tree has 7 nodes with 1 child, 4 nodes with 2 children, 8 nodes with 3 children, 7 nodes with 4 children, and every other node is…
- DFS runs on the directed graph with adjacency lists A: BDE; B: E; C: AE; D: BF; E: –; F: BCG; G: –, starting at A, scanning lists in the…
- The weighted undirected graph A–E (19), A–F (20), B–F (2), C–D (25), C–E (10), C–F (7), D–E (18), D–F (8) has a unique MST. What is the…
- A complete binary tree (array form, all levels full except possibly the last, which is filled from the left) has 91 nodes. How many leaves…
- What is the minimum number of edges m such that EVERY simple undirected graph with 13 vertices and m edges is guaranteed to be connected?