PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Motive

Implement Union-Find for connectivity

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding and implementation of the Disjoint Set Union (Union-Find) data structure—including path compression and union by rank—and competency in processing online connectivity queries on undirected graphs, categorized under Coding & Algorithms in the graph algorithms and data structures domain.

  • Medium
  • Motive
  • Coding & Algorithms
  • Software Engineer

Implement Union-Find for connectivity

Company: Motive

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Onsite

Implement a Disjoint Set Union (Union-Find) data structure with path compression and union by rank. Support operations: make_set, find(x), union(x, y), and connected(x, y). Then, given an undirected graph with n nodes labeled 1..n and a list of edges, process q online connectivity queries efficiently. Analyze time and space complexity, and discuss edge cases such as duplicate unions and isolated nodes.

Quick Answer: This question evaluates understanding and implementation of the Disjoint Set Union (Union-Find) data structure—including path compression and union by rank—and competency in processing online connectivity queries on undirected graphs, categorized under Coding & Algorithms in the graph algorithms and data structures domain.

Related Interview Questions

  • Implement Union-Find and track components - Motive (Medium)
Motive logo
Motive
Aug 13, 2025, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
1
0

Implement a Disjoint Set Union (Union-Find) data structure with path compression and union by rank. Support operations: make_set, find(x), union(x, y), and connected(x, y). Then, given an undirected graph with n nodes labeled 1..n and a list of edges, process q online connectivity queries efficiently. Analyze time and space complexity, and discuss edge cases such as duplicate unions and isolated nodes.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Motive•More Software Engineer•Motive Software Engineer•Motive Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.