You are given an N-ary tree of machines (one process per node). Each node knows its parent (if any) and its list of children. Nodes communicate via asynchronous message passing.
Goal: Design the per-node logic so that when any node initiates a count, exactly two message types (REQUEST_COUNT and REPLY_COUNT) are used to compute the total number of nodes in the entire tree and return it to the initiator. Each node must contribute exactly once; no double counting; protect critical sections.
Assume the runtime invokes call(Node from, Message message) on a node upon message arrival, and the initiator can trigger the protocol locally (e.g., startCount()).
Specify:
(a) Message format and fields.
(b) Per-node state you maintain.
(c) How a node propagates requests to neighbors (parent/children) and aggregates replies.
(d) How you prevent duplicate propagation when a node receives multiple requests for the same traversal.
(e) How the initiator detects termination and returns the global count.
(f) Assumptions about concurrency and delivery (e.g., out-of-order messages, at-most-once vs. at-least-once) and the time/message complexity of your approach.
Login required