The GATE Grind

GATE 2021 CS (CS2) – Question 65

Algorithms · Graph Algorithms: Traversals, Minimum Spanning Trees, Shortest Paths · 2 marks · Numerical answer

In the DAG shown with source s, a path’s quality is the product of its edge weights. A vertex’s quality is the maximum path quality from s; quality(s)=1. Find the sum of vertex qualities.

Diagram for GATE 2021 CS (CS2) question 65

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: 929 to 929

Explanation

Process vertices in topological order, propagating products and taking maxima. The qualities are s=1, a=9, b=9, c=1, d=9, e=81, f=9, g=81, t=729. For example d→e has weight nine, giving e=81; e→t has weight nine, giving t=729. Their sum is 1+9+9+1+9+81+9+81+729=929.

More Graph Algorithms: Traversals, Minimum Spanning Trees, Shortest Paths questions

All Graph Algorithms: Traversals, Minimum Spanning Trees, Shortest Paths questions →