GATE CS 2020 Set 1 — Question 41
Go beyond PYQs with Success TrackerAI-powered personalised practice and doubt support. Unlimited practice on eligible plans; AI usage limits apply.MCQ+2 / -0.67MediumKruskal's MSTGreedy AlgorithmsAlgorithmsPrim's MSTTree TraversalsTreesProgramming & Data StructuresCycle DetectionGraph Algorithms
Algorithms → Graph Algorithms → Cycle Detection
Last updated
Question
Let be a weighted undirected graph and let be a Minimum Spanning Tree (MST) of maintained using adjacency lists. Suppose a new weighted edge is added to . The worst case time complexity of determining if is still an MST of the resultant graph is
Correct answer
(D) Θ(V)
Solution
When a new edge is added to the graph , it creates a unique cycle in . For to remain an MST, the weight of the new edge must be greater than or equal to the weight of every edge on the unique path between and in . If is strictly less than the weight of the heaviest edge on this path, then is no longer an MST (we could swap the heaviest edge with to get a lighter tree).To determine this:
1.Find the unique path between and in .
2.Find the maximum weight edge on this path.
3.Compare it with .
Since is a tree with vertices and edges, finding the path between two nodes using BFS or DFS takes O(V) time. The number of edges in is O(V), so the traversal is proportional to the number of vertices. We do not need to traverse any edges of outside of . Thus, the worst-case time complexity is .Continue learning with Success Tracker
A step still unclear? Work through it with support
Use Success Tracker to ask about the reasoning, then try another GATE CS question to check your understanding.
AI-powered practice· Unlimited practice on eligible plans
- PYQs with solutions
- Attempt available previous-year questions, then compare your reasoning with the worked solution. Coverage varies by stream.
- Practice that adapts
- Choose a topic, work on weaker areas and bookmark questions to revisit. Your attempts feed your progress tracking.
- AI doubt support
- Ask follow-up questions about a step or concept while practising, instead of stopping at the final answer.
Unlimited practice is available on eligible plans. Free practice and AI usage have limits; check the current plan allowances before choosing.
This page stays readable without an account. AI responses can be wrong; check them against the solution and source material.
More questions on Graph Algorithms
2026 Set 2 Q12The set T represents various traversals over binary tree. The set S represents the order of…2026 Set 1 Q17Consider the following recurrence relations: For all ,…2026 Set 2 Q19Consider the following three ANSI-C programs, P1, P2, and P3. P1 [code] P2 [code] **P3**…2026 Set 1 Q23Let be an odd number greater than 100. Consider a binary minheap with elements stored in an…2026 Set 2 Q24Consider the following functions, where is a positive integer.…