chapter
    Minimum Spanning Trees and Shortest Paths PYQs for GATE CS

    Solve 10+ Minimum Spanning Trees and Shortest Paths previous year questions for GATE CS with answers and detailed solutions. Free sample questions below.

    Try a question

    Answer it here to see how it works. Nothing is recorded until you sign in.

    Question 1
    2026 Slot Set2 PYQ
    Level 4: Challenger

    Let be a weighted directed acyclic graph with edges and vertices. Given and a source vertex in , which one of the following options gives the worst case time complexity of the fastest algorithm to find the lengths of shortest paths from to all vertices that are reachable from in ?

    Question 2
    2026 Slot Set1 PYQ
    Let be a simple, undirected, edge-weighted graph with unique edge weights.

    Which of the following statements about the minimum spanning trees (MST) of is/are true?
    Question 3
    2026 Slot Set1 PYQ
    Let be an undirected, edge-weighted graph with integer weights. The weight of a path is the sum of the weights of the edges in that path. The length of a path is the number of edges in that path.

    Let be a vertex in . For every and for every , let denote the weight of a shortest path (in terms of weight) from to of length at most . If there is no path from to of length at most , then .

    Consider the statements:

    S1: For every and , .

    S2: For every , if is part of a shortest path (in terms of weight) from to , then for every , .

    Which one of the following options is correct?
    Question 4
    2025 Slot Set2 PYQ
    Level 4: Challenger
    Let be an edge-weighted undirected graph with positive edge weights. Suppose a positive constant is added to the weight of every edge.

    Which ONE of the following statements is TRUE about the minimum spanning trees (MSTs) and shortest paths (SPs) in before and after the edge weight update?
    Question 5
    2025 Slot Set1 PYQ

    Let be any undirected graph with positive edge weights, and be a minimum spanning tree of . For any two vertices, and , let and be the shortest distances between and in and , respectively. Which ONE of the options is CORRECT for all possible , , and ?

    Question 6
    2025 Slot Set1 PYQ
    The maximum value of such that the edge between the nodes B and C is included in every minimum spanning tree of the given graph is ________ . (answer in integer)

    ABDC768x31
    Question 7
    2024 Slot Set2 PYQ
    Level 4: Challenger
    The number of distinct minimum-weight spanning trees of the following graph is __________

    abfgced121332222211
    Question 8
    2022 PYQ
    Level 4: Challenger

    Consider a simple undirected weighted graph , all of whose edge weights are distinct. Which of the following statements about the minimum spanning trees of is/are TRUE?

    Question 9
    2021 Slot Set2 PYQ
    Let be a connected undirected weighted graph. Consider the following two statements.

    There exists a minimum weight edge in which is present in every minimum spanning tree of .
    If every edge in has distinct weight, then has a unique minimum spanning tree.

    Which one of the following options is correct?
    Question 10
    2021 Slot Set1 PYQ
    Level 4: Challenger
    Consider the following undirected graph with edge weights as shown:

    0.1 0.1 0.1 0.9 0.9 0.1 0.9 0.1 0.9 0.1 0.9 0.1

    The number of minimum-weight spanning trees of the graph is __________.
    Free preview ends here

    Login to view the complete previous-year questions and solutions

    Creating an account is free. You get the rest of this chapter, step-by-step solutions, and a study plan built around the topics you are actually weak at.

    Why MastersUp

    Personalised first. High quality throughout.

    Most platforms hand everyone the same content. Here the content moves with your performance, topic by topic.

    Built around you, not around a syllabus PDF

    Every answer you give moves your topic-level intelligence rate. The next question, the next revision card and tomorrow's plan all change with it.

    Revision that hits your weak spots

    We only revise topics you have actually attempted and are still below the safe bar on — never the same chapter on repeat.

    Questions calibrated to the real exam

    Each question carries a measured toughness. You are served a rung above your current level, so practice keeps stretching you.

    Notes written for recall, not for volume

    Full lesson cards for first study, curated short-note cards for the last mile — with derivations, traps and exam patterns marked.

    One place for everything

    Notes, chapter practice, previous-year questions, test series and full-length papers — all feeding one picture of your preparation.

    Honest progress

    No vanity streaks. Progress here means chapters mastered and accuracy that held up on harder questions.

    Unlock the whole course

    Full notes and short notes, the complete question bank with worked solutions, mock tests, full-length papers, and an adaptive plan that rebuilds itself as you improve.

    Minimum Spanning Trees and Shortest Paths PYQs for GATE CS

    Solve 10+ Minimum Spanning Trees and Shortest Paths previous year questions for GATE CS with answers and detailed solutions. Free sample questions below.

    Chapter Journey: Minimum Spanning Trees and Shortest Paths

    Chapter Roadmap

    Your journey through graph optimization algorithms.

    1
    MST Cut-Cycle Properties and Uniqueness

    The theoretical foundation. (You are here)

    2
    MST Construction and Counting

    Kruskal's, Prim's, and counting distinct trees.

    3
    Shortest-Path Properties and Algorithms

    Dijkstra, Bellman-Ford, and path relaxations.

    4
    Effects of Edge-Weight Transformations

    Adding constants, scaling, and structural impacts.

    MST Cut-Cycle Properties and Uniqueness

    Algorithms › Minimum Spanning Trees

    Cut-Cycle Properties & Uniqueness

    The theoretical engine behind every MST algorithm.

    What you will master:
    • Defining cuts and cycles in graph theory.
    • The Cut Property: identifying "safe" edges.
    • The Cycle Property: identifying "unsafe" edges.
    • Conditions that guarantee a unique Minimum Spanning Tree.

    Minimum Spanning Trees and Shortest Paths: Solved Questions with Step-by-Step Explanations (10 Problems)

    Question 1 · Algorithms · 2026_Set2 MCQ

    Let be a weighted directed acyclic graph with edges and vertices. Given and a source vertex in , which one of the following options gives the worst case time complexity of the fastest algorithm to find the lengths of shortest paths from to all vertices that are reachable from in ?

    1. A.

    2. B.

    3. C.

    4. D.

    Correct Answer:

    A

    Step-by-Step Solution

    Key idea: Shortest paths in a Directed Acyclic Graph (DAG) can be found in linear time using topological sorting.

    Step 1: Recognize that the graph is a DAG. This is the crucial condition that allows a faster algorithm than Dijkstra's or Bellman-Ford.

    Step 2: Perform a topological sort of the vertices. This takes time using DFS or Kahn's algorithm.

    Step 3: Initialize the distance to the source vertex as 0, and all other vertices as .

    Step 4: Process each vertex in topological order. For each outgoing edge with weight , relax the edge: if , update .

    Step 5: Since each vertex and each edge is processed exactly once in the topological order, the relaxation step takes time.

    Answer:

    Question 2 · Algorithms · 2026_Set1 MSQ
    Let be a simple, undirected, edge-weighted graph with unique edge weights.

    Which of the following statements about the minimum spanning trees (MST) of is/are true?
    1. A.

      In every cycle of , the edge with the largest weight in is not in any MST

    2. B.

      In every cycle of , the edge with the smallest weight in is in every MST

    3. C.

      For every vertex , the edge with the largest weight incident on is not in any MST

    4. D.

      For every vertex , the edge with the smallest weight incident on is in every MST

    Question 3 · Algorithms · 2026_Set1 MCQ
    Let be an undirected, edge-weighted graph with integer weights. The weight of a path is the sum of the weights of the edges in that path. The length of a path is the number of edges in that path.

    Let be a vertex in . For every and for every , let denote the weight of a shortest path (in terms of weight) from to of length at most . If there is no path from to of length at most , then .

    Consider the statements:

    S1: For every and , .

    S2: For every , if is part of a shortest path (in terms of weight) from to , then for every , .

    Which one of the following options is correct?
    1. A.

      Only S1 is true

    2. B.

      Only S2 is true

    3. C.

      Both S1 and S2 are true

    4. D.

      Neither S1 nor S2 is true

    Question 4 · Algorithms · 2025_Set2 MCQ
    Let be an edge-weighted undirected graph with positive edge weights. Suppose a positive constant is added to the weight of every edge.

    Which ONE of the following statements is TRUE about the minimum spanning trees (MSTs) and shortest paths (SPs) in before and after the edge weight update?
    1. A.

      Every MST remains an MST, and every SP remains an SP.

    2. B.

      MSTs need not remain MSTs, and every SP remains an SP.

    3. C.

      Every MST remains an MST, and SPs need not remain SPs.

    4. D.

      MSTs need not remain MSTs, and SPs need not remain SPs.

    Correct Answer:

    C

    Step-by-Step Solution

    Key idea: Adding a constant to all edge weights affects paths and spanning trees differently based on the number of edges.

    Step 1: Analyze the effect on Minimum Spanning Trees (MSTs). Every spanning tree of a graph with vertices has exactly edges. If a constant is added to every edge, the total weight of any spanning tree increases by exactly . Since this increase is uniform for all spanning trees, their relative weight ordering remains unchanged. Thus, every MST remains an MST.

    Step 2: Analyze the effect on Shortest Paths (SPs). A path's total weight increases by , where is the number of edges in the path. A previously shortest path with many edges might see its weight increase more than an alternative path with fewer edges but a slightly higher original weight. Thus, shortest paths need not remain shortest paths.

    Answer: Every MST remains an MST, and SPs need not remain SPs.

    Question 5 · Algorithms · 2025_Set1 MCQ

    Let be any undirected graph with positive edge weights, and be a minimum spanning tree of . For any two vertices, and , let and be the shortest distances between and in and , respectively. Which ONE of the options is CORRECT for all possible , , and ?

    1. A.

    2. B.

    3. C.

    4. D.

    Question 6 · Algorithms · 2025_Set1 NAT
    The maximum value of such that the edge between the nodes B and C is included in every minimum spanning tree of the given graph is ________ . (answer in integer)

    ABDC768x31
    Question 7 · Algorithms · 2024_Set2 NAT
    The number of distinct minimum-weight spanning trees of the following graph is __________

    abfgced121332222211
    Correct Answer:

    9

    Step-by-Step Solution

    Key idea: Use Kruskal's algorithm to group edges by weight and count the number of valid ways to connect the resulting components.

    Step 1: List all edges grouped by weight.

    Weight 1: (a,b), (a,f), (c,d), (e,d) 4 edges.

    Weight 2: (a,g), (b,g), (f,g), (g,c), (g,e), (g,d) 6 edges.

    Weight 3: (b,c), (f,e) 2 edges.

    Step 2: Process weight 1 edges. They form two disjoint tree components without cycles:

    • Component 1: {a, b, f} (using edges a-b, a-f)
    • Component 2: {c, d, e} (using edges c-d, e-d)

    Vertex {g} is isolated. Total components = 3.

    Step 3: A spanning tree for 7 vertices requires exactly edges. We already have 4 edges of weight 1. We need exactly 2 more edges to connect the 3 components.

    Step 4: Look at weight 2 edges. They connect {g} to Component 1 via 3 edges: (a,g), (b,g), (f,g). They connect {g} to Component 2 via 3 edges: (g,c), (g,e), (g,d).

    There are no weight 2 edges directly between Component 1 and Component 2.

    Step 5: To connect all 3 components, we must choose exactly one edge from the first group (3 choices) and exactly one edge from the second group (3 choices).

    Step 6: Total distinct MSTs = . (Weight 3 edges are not needed as the graph is already connected with weight 1 and 2 edges).

    Answer: 9

    Question 8 · Algorithms · 2022 MSQ

    Consider a simple undirected weighted graph , all of whose edge weights are distinct. Which of the following statements about the minimum spanning trees of is/are TRUE?

    1. A.

      The edge with the second smallest weight is always part of any minimum spanning tree of .

    2. B.

      One or both of the edges with the third smallest and the fourth smallest weights are part of any minimum spanning tree of .

    3. C.

      Suppose be such that and . Consider the edge with the minimum weight such that one of its vertices is in and the other in . Such an edge will always be part of any minimum spanning tree of .

    4. D.

      can have multiple minimum spanning trees.

    Correct Answer:

    ["A","B","C"]

    Step-by-Step Solution

    Key idea: Apply the Cut Property and Kruskal's algorithm logic to a graph with strictly distinct edge weights.

    Step 1: Analyze the distinct weights condition. Since all edge weights are distinct, the Minimum Spanning Tree (MST) of the graph is strictly unique. This immediately makes the statement "G can have multiple minimum spanning trees" FALSE.

    Step 2: Evaluate the smallest edges. Let the edges sorted by weight be

    By Kruskal's algorithm, is always included.

    Step 3: Evaluate . Can form a cycle with ? No, because a cycle requires at least 3 edges in a simple graph. Thus, will never be rejected by Kruskal's and is always in the MST. Statement A is TRUE.

    Step 4: Evaluate and . For an edge to be rejected by Kruskal's, it must form a cycle with edges already in the MST. The only edges smaller than are and . These two edges can form at most one path of length 2 (if they share a vertex). Therefore, they can form a cycle with at most ONE additional edge (which would be ).

    Step 5: Since and can only cause the rejection of at most one edge (the one closing their cycle), they cannot cause the rejection of BOTH and . Thus, at least one of or must be accepted into the MST. Statement B is TRUE.

    Step 6: Evaluate the cut property. The statement describes exactly the Cut Property: the minimum weight edge crossing any cut is always part of the MST. Since weights are distinct, this minimum is unique. Statement C is TRUE.

    Answer: A, B, C

    Question 9 · Algorithms · 2021_Set2 MCQ
    Let be a connected undirected weighted graph. Consider the following two statements.

    There exists a minimum weight edge in which is present in every minimum spanning tree of .
    If every edge in has distinct weight, then has a unique minimum spanning tree.

    Which one of the following options is correct?
    1. A.

      Both and are true.

    2. B.

      is true and is false.

    3. C.

      is false and is true.

    4. D.

      Both and are false.

    Question 10 · Algorithms · 2021_Set1 NAT
    Consider the following undirected graph with edge weights as shown:

    0.1 0.1 0.1 0.9 0.9 0.1 0.9 0.1 0.9 0.1 0.9 0.1

    The number of minimum-weight spanning trees of the graph is __________.
    Correct Answer:

    3

    Step-by-Step Solution

    Key idea: Use Kruskal's algorithm to find the MST, grouping edges by weight and counting the number of valid choices at each step.

    Step 1: Identify all edges and their weights. The graph is a grid.

    Weight 0.1 edges (7 total): Top row horizontal (2), middle row left horizontal (1), bottom row right horizontal (1), left column bottom vertical (1), middle column bottom vertical (1), right column bottom vertical (1).

    Weight 0.9 edges (5 total): The remaining edges.

    Step 2: Process weight 0.1 edges. These 7 edges connect the 9 vertices into exactly 2 connected components without forming any cycles:

    • Component 1: Top row (3 vertices, connected by 2 horizontal edges).
    • Component 2: The remaining 6 vertices, connected by the other 5 weight 0.1 edges in a tree structure.

    Step 3: To form a spanning tree of the 9 vertices, we need exactly edges. We already have 7 edges of weight 0.1. We need exactly 1 more edge to connect Component 1 and Component 2.

    Step 4: Identify the edges connecting Component 1 and Component 2. These are the 3 vertical edges in the top half of the grid, all of which have weight 0.9.

    Step 5: We can choose any 1 of these 3 edges to complete the MST. Each choice yields a valid MST of weight .

    Answer: 3

    More previous year questions (pyqs) in this unit