## 5 Algorithm
### Detailed Algorithm Description  
Now, we introduce several variables that denote the state of the root/internal/leaf processes. * \(P_{i}\in\{N.i\cup\bot\}\): denotes \(i\)'s parent in the tree rooted at \(r\) and \(\bot\) if it is root \(r\). * \(S_{i}\in\{B,F,C\}\): denotes the primary phase process \(i\) is in where states \(B\), \(F\) and \(C\) denote the broadcast, the feedback, and the cleaning phases, respectively. In addition, \(S_{i}\)=\(B\) denotes that process \(i\) has received message \(M\) directly or indirectly from root \(r\). When \(S_{i}=F\) and \(S_{i}=C\) holds, it indicates that process \(i\) is involved in feedback, acknowledgment of the completion of the broadcast, and cleaning, clearing of the traces of the broadcast and phases, respectively. * \(S^{{}^{\prime}}_{i}\in\{f,b,c\}\) : denotes the secondary wave phase process \(i\) is in where states \(f\), \(b\), and \(c\) denote the \(f\)-, \(b\)-, and \(c\)-phases, respectively. A process \(i\) is in state \(c\) (\(S^{{}^{\prime}}_{i}=c\)) when it is in the \(c\)-phase of the secondary wave, indicating that the process is not currently involved in a secondary wave. If the state of a process is either \(F\) or \(C\) in a normal broadcast tree, a process \(i\) is always in state \(c\). A process \(i\) is in state \(f\) (\(S^{{}^{\prime}}_{i}=f\)) when it is in the \(f\)-phase of the secondary wave, in a bottom-up manner, the collection of \(ids\) of the boundary, the leaf, and the neighbors of the boundary processes takes place. Similarly, process \(i\) is in state \(b\) (\(S^{{}^{\prime}}_{i}=b\)) when it is in the \(b\)-phase of the secondary wave where the designated parenthood information decided by root process \(i\) (based on the collected information) is forwarded to the boundary and the level \(l+2\) processes in a top-down manner. * \(L_{i}\in\{1,2,\cdots,N\}\): denotes the distance of process \(i\) from root \(r\). * \(lock_{i}\in\{\mathbf{true},\mathbf{false}\}\): denotes whether or not process \(i\) is locked. * \(NeighInfo_{i}\in\{t_{0},t_{1},t_{2},...,\emptyset\}\): contains the tuples containing the \(ids\) of the descendants of process \(i\) in the broadcast tree that are neighbors of the boundary, the leaves and boundary processes to be forwarded to the root using the bottom-up \(f\)-phase of the secondary wave where \(t_{k}\), \(k\geq 0\), is a tuple of the form \(<ID,L\), \(Neigh>\), where \(ID\) is the id of the leaf or the boundary process from which information is collected, \(L\) is the level of the process from which the information is collected, and \(Neigh\) is the neighbors ids if the process from which information is collected is a boundary process. * \(CorrInfo_{i}\in\{t_{0},t_{1},t_{2},...,\emptyset\}\): denotes the tuples with the designated parenthood information decided by the root process and is used to forward designated parenthood information to the boundary and level \(l+2\) processes by the top-down secondary wave in the broadcast tree, where \(t_{k}\), \(k\geq 0\), is a tuple of form \(<\)_targetNode_, \(Parent>\). We denote the state of a process \(i\) in the form \(Xy\) where \(S_{i}=X\) and \(S^{{}^{\prime}}_{i}=y\) indicate that the process is in phase \(X\) and \(y\) of the primary and the secondary waves, respectively; e.g., process \(i\) in state \(Cc\) indicates that \(S_{i}=C\wedge S^{{}^{\prime}}_{r}=c\) holds. Root process \(r\) starts a primary wave in a _normal starting system configuration_ where the root process \(r\) is in state \(Cc\), \(input()\) holds and for each of its neighbor \(i\), \(P_{i}=r\wedge S_{i}=C\wedge S^{{}^{\prime}}_{i}=c\wedge L_{i}=1\wedge lock_{i}\) holds by entering state \(Bc\) (\(S_{r}=B\wedge S^{{}^{\prime}}_{r}=c\)) (Guards \(rB\) and \(iC1\)). This results in a broadcast tree consisting of process \(r\) in the broadcast phase with all of its neighbors included in the tree as boundary processes. Subsequently, a secondary wave is initiated which results in extending the broadcast tree to all the neighbors of the boundary.