Skip to content

Commit 57e4535

Browse files
authored
Update README.md
1 parent 0fd07f8 commit 57e4535

File tree

1 file changed

+0
-7
lines changed
  • 23 - Graph Data Structure Problems/15 - Minimum Spanning Tree | Kruskal's Algorithm | Disjoint Set | Union by Rank and Path Compresion

1 file changed

+0
-7
lines changed

23 - Graph Data Structure Problems/15 - Minimum Spanning Tree | Kruskal's Algorithm | Disjoint Set | Union by Rank and Path Compresion/README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -269,14 +269,10 @@ Thus, when both **union by rank** and **path compression** are used, the operati
269269

270270
### Kruskal's Algorithm
271271

272-
### **Kruskal's Algorithm**
273-
274272
Kruskal's algorithm is a **greedy algorithm** used to find the **minimum spanning tree (MST)** of a connected, undirected graph. The MST is a subset of the edges of the graph that connects all the vertices together without any cycles, and the sum of the weights of the edges is minimized.
275273

276274
The algorithm works by sorting all the edges of the graph in increasing order of their weights and adding them one by one to the MST, ensuring no cycle is formed.
277275

278-
---
279-
280276
### **Steps Involved in Kruskal's Algorithm:**
281277

282278
1. **Sort all edges** of the graph in non-decreasing order of their weights.
@@ -288,16 +284,13 @@ The algorithm works by sorting all the edges of the graph in increasing order of
288284
4. Repeat step 3 until we have added **(V - 1)** edges to the MST, where **V** is the number of vertices in the graph.
289285
5. The result will be the **Minimum Spanning Tree** of the graph.
290286

291-
---
292287

293288
### **Time Complexity of Kruskal's Algorithm:**
294289

295290
- Sorting the edges takes **O(E log E)** time, where **E** is the number of edges.
296291
- The **find** and **union** operations on the disjoint set take **O(α(V))** time, where **V** is the number of vertices and **α** is the inverse Ackermann function, which grows very slowly and is practically constant for all reasonable input sizes.
297292
- Thus, the overall time complexity of Kruskal's algorithm is **O(E log E)**, which is dominated by the edge sorting step.
298293

299-
---
300-
301294
### **Kruskal's Algorithm: Example**
302295

303296
Let’s go through an example to understand how Kruskal's algorithm works.

0 commit comments

Comments
 (0)