BIT201 ยท 2082 ยท 5 marks
Define time and space complexity. Discuss about Round Robin Algorithm for MST. [1+4]
Define time and space complexity. Discuss about Round Robin Algorithm for MST. [1+4]
Quick answer
Selected edges (removing duplicates): C-F(1), B-C(2), B-E(3), A-B(4), D-E(5)
Time and Space Complexity + Round Robin Algorithm for MST
(a) Time and Space Complexity
Time Complexity
Time complexity is a measure of the amount of time (number of basic operations) an algorithm takes to complete as a function of the input size n. It describes how the running time grows with increasing input.
Example: Linear search has time complexity O(n).
Space Complexity
Space complexity is a measure of the amount of memory space an algorithm requires as a function of the input size n. It includes both auxiliary space and space used by the input.
Example: An algorithm storing an n x n matrix has space complexity O(nยฒ).
(b) Round Robin Algorithm for MST
Background
The Round Robin (also called Boruvka's Algorithm) is one of the oldest algorithms for finding a Minimum Spanning Tree (MST) of a weighted, connected, undirected graph.
- Proposed by Otakar Boruvka in 1926.
- It works by simultaneously growing multiple components and merging them.
Key Idea
In each round (phase), every component (initially each vertex is its own component) selects the minimum weight edge that connects it to a different component. All such edges are added to the MST, and components are merged.
Algorithm Steps
Input: Graph G = (V, E) with weighted edges
Output: Minimum Spanning Tree T
1. Initialize each vertex as its own component.
T = {} (empty set of MST edges)
2. Repeat until only one component remains:
a. For each component C:
- Find the minimum weight edge (u, v) such that
u โ C and v โ C (cheapest outgoing edge).
b. Add all such selected edges to T
(avoid duplicates if two components select the same edge).
c. Merge the connected components.
3. Return T as the MST.
Example
Consider the graph:
4 2
A ------B ------C
| | |
6| |3 |1
| | |
D ------E ------F
5 8
Edges: A-B(4), B-C(2), A-D(6), B-E(3), C-F(1), D-E(5), E-F(8)
Round 1: Each vertex is its own component {A},{B},{C},{D},{E},{F}
| Component | Cheapest Edge |
|---|---|
| A | A-B (4) |
| B | B-C (2) |
| C | C-F (1) |
| D | D-E (5) |
| E | B-E (3) |
| F | C-F (1) |
After merging: {A,B,C,E,F} and {D} merge further -> one component.
MST edges: C-F, B-C, B-E, A-B, D-E
Total Weight: 1+2+3+4+5 = 15
Complexity Analysis
| Measure | Value |
|---|---|
| Time Complexity | O(E log V) |
| Space Complexity | O(V + E) |
- Each phase reduces the number of components by at least half.
- So there are at most O(log V) phases.
- Each phase scans all E edges.
Advantages
- Naturally parallelizable (all components work simultaneously).
- Efficient for dense graphs.
- Works well in distributed computing environments.
Summary
Boruvka's Round Robin Algorithm builds the MST by repeatedly selecting the minimum cost edge from each component and merging components until a single spanning tree is formed, achieving O(E log V) time complexity.
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.