Give n number of underground bunkers (some online and some offline), write code to desseminate your message to other nodes and desseminate messages from other nodes to other nodes without forming a cycle. Online nodes forward messages when received, offline nodes are abandoned and no messages are forwarded.
e.g.
A --> B --> C --> E
| |
D -->F-->Gwrite code that could be run on all sites, and could propagate messages without forming a cycle.
The following template is provided, interviewee is expected to fill in the blanks:
public class Transceiver {
public class Message {
...
}
public void receive(Message message) {
...
}
public void send(Message message) {
...
}
}Assume all nodes run updated code immediately. Solution must propagate messagaes to all nodes without getting in infinite loop.