Algorithm · OpenAI · Hard
A distributed system is laid out as a rooted n-ary tree in which every node is a separate machine. Each machine has a unique string ID in the range 0 to n - 1, knows the ID of its parent (the root's parent is -1), and keeps a list holding the IDs of its children. A node may exchange messages only with its direct parent and its direct children, through a messaging API you are given; messages can flow in both directions. An external client kicks off every operation by sending…