## 5 Design of Greedy Grouping Algorithm
This means that the memory requirements must be slightly higher than a delay-bandwidth product. In addition, our scheme uses a dynamic cache update scheme, which periodically scans expired packets, so the cache space is not very large. While a sink node can overhear the encoding combinations generated by every sink node in the WBAN, this can createa lot of coding opportunities for sinks. At the expense of this overhead, the proposed fault-tolerant mechanism performs better than traditional schemes in reducing packet loss ratio, end-to-end delay, and resource redundancy degree, and in increasing useful throughput ratio. Therefore, it is worthwhile to pay a small amount of overhead. A set of sensor nodes that dispatch messages can be considered a group. We can assign a label to a group with a sequence number ID. The decoding process will begin when the destination nodes have received enough native messages with the same sequence number ID. In random linear network coding, the packet information and encoding vectors are mixed at each coding node according to a local coding method. Therefore, the destination node does not need to obtain the knowledge of the whole network topology and global encoding information to recover the native packets. If the rank of matrix made up of global encoding vectors is equal to the number of native packets in each round, the native packets can be released at last. Therefore, as long as the number of linearly independent packets received by destination node is equal to or larger than the number of native packets, all of the native packets can be recovered with high probability through the GE method for solving linear equations over finite fields. The greedy grouping will first select the candidate sensors with the largest number of neighbour nodes and put them into a grouping labelled as group 1. This selection method can ensure that many connections with \(L_{s}\) nodes can be kept to produce more coding opportunities. The selection method continues putting sensors into this group with the same sequence number until the accumulated degree of this set is not equal to \(h-1\). When group 1 is complete, a subsequent series of groups will be constructed in sequence using this grouping strategy until all sensors are covered, when the greedy grouping algorithm ends. This greedy grouping strategy chooses the source sensors with the most neighbour nodes at every grouping stage. In this way, our greedy algorithm particularly tries to create coding opportunities without regarding other factors that may influence network performance. Therefore, this grouping scheme satisfies the optimal requirement from the local perspective. Globally, however, the optimal grouping combinations are not necessarily achieved [33; 34].The pseudo-code of the network coding algorithm is given in Table 3 below. \begin{table}
\begin{tabular}{l} \hline \hline
**Algorithm for Constructing Greedy Grouping** \\ \hline
1: Define the variable \\
2: Stores the scheduled source node, \(SchdstSet=\phi\); \\
3: Initialize the encoding group number, \(coding\_lable=0\); \\
4: Initialize the cluster number, \(cluster\_id=0\); \\
5: Start grouping \\
6: Initialize source node index in group, \(index=0\); \\
7: Calculate the minimum cut \(h\) between \(L_{s}\) and destination node \\
8: Define a boolean variable Found, If the source node joins the current cluster, it is true, \(Found=TRUE\); \\
9: \(While(|Schdst|<|L_{s}|)\) do \\
10: \(x=\phi\); \\
11: \(if(index>h-2||Found==FALSE)\) then \\
12: \(cluster\_id++\); \\
13: \(index++\); \\
14: **End if** \\
15: \(coding\_lable++\); \\
16: x=[choose the sensor u with maximum connectivity degree], \(u\
otin Schdst\) \\
17: \(if(x==\phi)\) then \\
18: \(Found=FALSE\); \\
19: **Else** \\
20: \(SchdstSet=SchdstSet\cup x\); \\
21: \(Schedule[cluster\_id][index]=x\); \\
22: Complete a node grouping, jump to the next one \\
23: **End if** \\
24: **End While** \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Pseudo-Code of Greedy Grouping Algorithm.