Skip to content

PRO TIP Block youtube.com at the DNS level — Pi-hole, NextDNS or your hosts file — but allow youtube-nocookie.com and i.ytimg.com. These tutorials keep playing; the rabbit hole does not.

Learning without distractions

DSA in Python – Disjoint Set (Union-Find) | Path Compression + Union by Size/Rank | Part 158 [Hindi]

2.4K views on YouTube

📘 Welcome to Part 158 of Code & Debug’s DSA Python Course!

In this video, we dive into one of the most powerful data structures for graph problems – Disjoint Set Union (DSU), also known as Union-Find.

Disjoint Set is widely used in problems related to connected components, cycle detection, and Minimum Spanning Trees (Kruskal’s Algorithm).

👨‍🏫 Here’s what we cover in this video:
✅ What is a Disjoint Set and where it’s used
✅ find() function with Path Compression for optimization
✅ union() with Union by Size strategy
✅ Full code walkthrough and working demo
✅ Time Complexity explanation – almost O(1) due to inverse Ackermann function
✅ Real-world examples of usage

This foundational concept appears in many advanced graph problems, and mastering it is crucial for acing competitive programming and interviews.

📄 Full Playlist Sheet (All Questions in Order):
https://docs.google.com/spreadsheets/d/1AWE15Fy3wD2iqu2vjK_R7cCiuvSsjYQclcdZmHpF66o/edit?usp=sharing

🎓 Enroll in the FREE Python DSA Course:
https://codeanddebug.in/course/master-dsa-with-leetcode

🚀 For a complete journey from beginner to expert:
https://codeanddebug.in/course/zero-to-hero-python-dsa

Keep learning and stay consistent with Code & Debug.
Like | Share | Subscribe & turn on the 🔔 for updates!

#DisjointSet #UnionFind #PathCompression #UnionBySize #PythonDSA #GraphDSA #DSA2025 #CodeAndDebug #Part158 #ConnectedComponents #KruskalAlgorithm #GraphTheory