Data Structures & AlgorithmsHardProduct-company placement
Dijkstra's algorithm runs from A on the directed graph A→C (4), B→A (1), B→F (6), C→B (7), C→E (12), C→F (6), D→C (3), E→A (15), E→B (3), E→F (11), F→D (7). In what order are the vertices finalised (removed from the priority queue)?
- A. A C B E F D
- B. A B E C D F
- C. A C F B E D
- D. A C B D E F
Correct answer: C. A C F B E D
Vertices leave the queue in increasing final distance: A=0, C=4, F=10, B=11, E=16, D=17. Ordering by hop count, by Prim-style cheapest edge, or by the direct edge from A ignores cheaper multi-edge routes.
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 weighted undirected graph A–B (27), A–D (3), A–E (1), B–C (25), B–D (8), B–E (18), B–F (5), C–E (9) has a unique MST. What is the…
- A simple undirected graph has 13 vertices and exactly 4 connected components. What is the maximum possible number of edges?
- What is the length of the shortest string that has BOTH COMPILER and SHORTEST as subsequences (shortest common supersequence)?
- Prim's algorithm starts at G on the weighted undirected graph A–B (19), A–F (12), A–G (21), B–C (13), B–D (23), B–E (6), B–G (29), D–E…
- The weighted undirected graph A–B (1), A–C (6), A–D (3), A–E (4), B–C (4), B–D (3), C–D (5) has repeated weights. How many different…
- A simple undirected graph has 9 vertices and exactly 4 connected components. What is the maximum possible number of edges?