Detect Partitions in a Drone Swarm Radio Network
Last updated: November 29, 2026
Quick Overview
Given the 2D positions of aircraft in a swarm and a radio range R, two aircraft can talk directly if they are within R of each other. Return the connected groups, avoiding an all-pairs comparison for large swarms.
Shield AI
November 29, 20260
0
0 solved
Given the 2D positions of aircraft in a swarm and a radio range R, two aircraft can talk directly if they are within R of each other. Return the connected groups, avoiding an all-pairs comparison for large swarms.
Multi-agent teaming in Hivemind depends on knowing which aircraft can still relay to each other, and a partitioned swarm needs a different behavior than a connected one. The question checks union-find, spatial hashing to beat O(n^2), and attention to the boundary distance case.
What the Interviewer Expects
- Models the network as a graph with edges at distance at most R
- Uses union-find or BFS to find components
- Buckets positions into cells of side R so only 9 neighboring cells are checked
- Compares squared distances to avoid sqrt
- Explains the worst case when everything sits in one cell
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Positions update at 10 Hz. How do you maintain components incrementally?
- Which single aircraft, if lost, would split the network? (articulation points)
- How would you choose where to move one relay drone to reconnect two groups?
- Range depends on terrain and antenna orientation. How does the model change?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: list of (x, y) and R > 0. Output: list of groups (lists of indices). Distance exactly R counts as connected. I would ask about swarm size: for 20 aircraft the O(n^2) check is fine, but for ...
High-Level Design
Place each aircraft in grid cell (floor(x/R), floor(y/R)). Any two aircraft within R must be in the same or an adjacent cell, so for each cell only compare against the 3x3 block around it. Union eve...