How many messages, and how long?
With nothing lost, the cost is exact. Every machine but the root gets one ask and sends one answer. So a count of n machines sends 2(n - 1) messages, whatever the shape.
Time is different. Say each message takes one round to arrive. The asks reach the bottom of the deepest path after depth rounds, and the answers need as many to come back. A count takes 2 × depth rounds.
| Tree of 100 machines | Messages | Rounds |
|---|---|---|
| a star, the root with 99 children | 198 | 2 |
| a chain, 99 links deep | 198 | 198 |
Same messages, about a hundred times slower. Two ways to say it when asked: the protocol is O(n) messages and O(depth) time. Retries add a timeout's wait each time a message is lost along the slowest path.
Depth bites code too. A recursive oracle on a chain of a thousand machines passes Python's default recursion limit of 1,000 calls. That's fine for the test trees, but worth saying before the interviewer asks.
The editor holds size and depth from the first step, and cost(tree, root) to write. Return the messages a count sends with nothing lost, and the rounds it takes.