PracHub
QuestionsLearningGuidesInterview Prep
|Home/Software Engineering Fundamentals/OpenAI

Count Machines and Recover a Distributed Tree Topology

Last updated: Jul 16, 2026

Quick Overview

Design a distributed tree protocol that counts machines and reconstructs all nodes and edges without a central inventory. Specify correlation-bound aggregation, retries, deduplication, termination, topology validation, snapshot semantics, and honest handling of unreachable subtrees.

  • medium
  • OpenAI
  • Software Engineering Fundamentals
  • Software Engineer

Count Machines and Recover a Distributed Tree Topology

Company: OpenAI

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Technical Screen

# Count Machines and Recover a Distributed Tree Topology A cluster's machines form a rooted tree. Design a protocol that returns the number of machines and, as a follow-up, reconstructs the tree topology without relying on a central inventory. ### Constraints & Assumptions - Practice assumption: every machine knows its own unique ID, parent, and immediate children. - Parent-child channels are bidirectional; messages may be delayed, duplicated, or retried. - Membership is stable during one requested snapshot. - A coordinator can contact the root but cannot directly query every machine. - A failed or unreachable machine must not be silently counted as a successful response. ### Clarifying Questions to Ask - Is the tree guaranteed to be valid, connected, and acyclic? - Is an exact point-in-time snapshot required? - What timeout and partial-result behavior should callers see? - How large and deep can the tree be? ### Part 1: Distributed Count Specify request, response, correlation, deduplication, aggregation, timeout, and retry behavior for counting every reachable machine exactly once. #### Hints - Each subtree can summarize itself. - A retry should not start an unrelated logical count. #### What This Part Should Cover - Termination and aggregation - Idempotent message handling - Explicit incomplete-result semantics ### Part 2: Tree Topology Extend the protocol to return all nodes and edges. Explain representation, memory and message costs, validation, and handling of duplicate or inconsistent child reports. #### Hints - A parent can combine child summaries without knowing the whole cluster beforehand. #### What This Part Should Cover - Unambiguous topology representation - Validation of tree invariants - Complexity and payload-size trade-offs ### Part 3: Dynamic or Failing Cluster Explain what changes when membership can change during the operation or a subtree is unavailable. #### Hints - Define the consistency guarantee before selecting a mechanism. #### What This Part Should Cover - Snapshot or version strategy - Partial failure behavior - Operational observability ### What a Strong Answer Covers - A correlation-bound convergecast protocol - Idempotency, termination, and honest failure semantics - Topology validation and O(n) cost reasoning - A defensible consistency model for dynamic membership ### Follow-up Questions - How would you avoid recursion limits on a very deep tree? - How could the root stream a huge topology rather than buffer it? - How would you detect an accidental cycle? - What if only an approximate count is needed continuously?

Quick Answer: Design a distributed tree protocol that counts machines and reconstructs all nodes and edges without a central inventory. Specify correlation-bound aggregation, retries, deduplication, termination, topology validation, snapshot semantics, and honest handling of unreachable subtrees.

Related Interview Questions

  • Clarify and Design Social-Graph Milestones - OpenAI (medium)
  • Implement A Mobile Chat Interface In An Existing Codebase - OpenAI (medium)
  • Refactor a Chatbot into Clean Object-Oriented Components - OpenAI (medium)
  • Implement a Simple Memory Allocator - OpenAI (medium)
|Home/Software Engineering Fundamentals/OpenAI

Count Machines and Recover a Distributed Tree Topology

OpenAI logo
OpenAI
Jul 3, 2026, 12:00 AM
mediumSoftware EngineerTechnical ScreenSoftware Engineering Fundamentals
7
0

Count Machines and Recover a Distributed Tree Topology

A cluster's machines form a rooted tree. Design a protocol that returns the number of machines and, as a follow-up, reconstructs the tree topology without relying on a central inventory.

Constraints & Assumptions

  • Practice assumption: every machine knows its own unique ID, parent, and immediate children.
  • Parent-child channels are bidirectional; messages may be delayed, duplicated, or retried.
  • Membership is stable during one requested snapshot.
  • A coordinator can contact the root but cannot directly query every machine.
  • A failed or unreachable machine must not be silently counted as a successful response.

Clarifying Questions to Ask Guidance

  • Is the tree guaranteed to be valid, connected, and acyclic?
  • Is an exact point-in-time snapshot required?
  • What timeout and partial-result behavior should callers see?
  • How large and deep can the tree be?

Part 1: Distributed Count

Specify request, response, correlation, deduplication, aggregation, timeout, and retry behavior for counting every reachable machine exactly once.

Hints

  • Each subtree can summarize itself.
  • A retry should not start an unrelated logical count.

What This Part Should Cover Guidance

  • Termination and aggregation
  • Idempotent message handling
  • Explicit incomplete-result semantics

Part 2: Tree Topology

Extend the protocol to return all nodes and edges. Explain representation, memory and message costs, validation, and handling of duplicate or inconsistent child reports.

Hints

  • A parent can combine child summaries without knowing the whole cluster beforehand.

What This Part Should Cover Guidance

  • Unambiguous topology representation
  • Validation of tree invariants
  • Complexity and payload-size trade-offs

Part 3: Dynamic or Failing Cluster

Explain what changes when membership can change during the operation or a subtree is unavailable.

Hints

  • Define the consistency guarantee before selecting a mechanism.

What This Part Should Cover Guidance

  • Snapshot or version strategy
  • Partial failure behavior
  • Operational observability

What a Strong Answer Covers Guidance

  • A correlation-bound convergecast protocol
  • Idempotency, termination, and honest failure semantics
  • Topology validation and O(n) cost reasoning
  • A defensible consistency model for dynamic membership

Follow-up Questions Guidance

  • How would you avoid recursion limits on a very deep tree?
  • How could the root stream a huge topology rather than buffer it?
  • How would you detect an accidental cycle?
  • What if only an approximate count is needed continuously?
Loading comments...

Browse More Questions

More Software Engineering Fundamentals•More OpenAI•More Software Engineer•OpenAI Software Engineer•OpenAI Software Engineering Fundamentals•Software Engineer Software Engineering Fundamentals

Write your answer

Your first approved answer each day earns 20 XP.

Sign in to write your answer.
PracHub

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

Product

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

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding 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.