Coding & Algorithms (DSA)
Union-Find / Disjoint Set
5 practice questions. Free questions open a full answer guide; the rest unlock with Pro.
- Two engineers implemented union-find but their solution is slow on large inputs because they only added one of the two standard optimizations. Walk me through path compression versus union by rank, why you need both, and what goes wrong with only one.
- Walk me through how you'd use union-find to detect a cycle while adding edges to an undirected graph, and where this shows up in real systems.Go Pro
- When would you reach for a union-find (disjoint-set) structure over running BFS or DFS to determine connectivity, and what does the inverse-Ackermann complexity claim actually mean for the runtime you can promise?Go Pro
- What problem does a union-find (disjoint-set) data structure solve, and what makes its operations nearly constant time?Go Pro
- If you're given a grid where cells are either land or water, how would you count the number of separate landmasses using union-find, and why might it be a better fit than a flood-fill?Go Pro
Want questions matched to your role? Paste a job title, job description, or CV for a personalized set, or go Pro to unlock the full bank.