Let be a weighted undirected graph and let be a Minimum Spanning Tree (MST) of maintained using adjacency lists. Suppose a new weighed edge is added to . The worst case time complexity of determining if is still an MST of the resultant graph is
View worked solution
Answer: D
To determine if the tree remains a Minimum Spanning Tree (MST) after adding a new weighted edge with weight , we can use the Cycle Property of MSTs.
1. Theoretical Background
When a new edge is added to the tree , it creates a unique cycle consisting of the edge and the unique path between and in .
- According to the cycle property, remains an MST of the new graph if and only if the newly added edge has the maximum weight in this cycle .
- In other words, is still an MST if and only if:
2. Algorithm and Time Complexity
To verify this condition, we perform the following steps:
- Find the unique path between vertices and in the tree using a standard graph traversal algorithm like Depth-First Search (DFS) or Breadth-First Search (BFS) starting from .
- During the traversal, keep track of the maximum edge weight encountered on the path to . Let this maximum weight be .
- Compare the weight of the new edge, , with . If , then remains an MST; otherwise, it does not.
Since is a tree, it contains exactly vertices and edges. Running DFS or BFS on a tree represented by adjacency lists takes time proportional to the number of vertices and edges in the tree:
Thus, the worst-case time complexity of determining if is still an MST is .
Free practice · Your answers on this page are not saved.
