A sensor network is organized by a tree T, where the root s corresponds to the base station which receives data from every other node. We assume the time is divided into a continuous sequence of slots of fixed length, starting from slot 0, 1, 2, .... Moreover, we assume:
(1) Every node (sensor) has a unit of data to send to its father which needs one time slot.
(2) A father node can receive only one unit of data in each time slot from one child.
(3) A father node cannot start sending data to its own father until he has received all data from his children.
(4) Once a node starts sending data, it cannot stop in the middle until finish. The number of time slots needed is equal to the total number of units of data received plus one for his own data.
(5) There are n leave nodes.
Design an O(n) algorithm that decides (schedules) for each node at which time slot to start sending data such that the total number of time (slots) is minimized. We assume the schedule stats from slot 0. The following figure shows an example.