## 4 Efficient Node Insertion Algorithm
### Description of Algorithm
If, with \(m=1\), no Wi-Fi node is available that is connected from \(m=1\), the most recently added node in the sequence, the current serially connected multipolling sequence that is being constructed should be closed, and a new serially connected multipolling sequence should begin to be constructed for the remaining Wi-Fi nodes that have not been selected. If \(m=\) a certain value \(n\) (\(>\)0), the Wi-Fi nodes are found that are simultaneously connected from the \(m=n\) most recently added nodes in the sequence, and the Wi-Fi nodes are searched that are simultaneously connected from the \(m=n+1\) most recently added nodes in the sequence. If with \(m=n\) (\(>\)1), no Wi-Fi node is found that is simultaneously connected from the \(m=n\) most recently added nodes in the sequence, to the current serially connected multipolling sequence, a random Wi-Fi node should be inserted that is simultaneously connected from the \(m=n-1\) (\(>\)0) most recently added nodes in the sequence. Continuing to construct serially connected multipolling sequences by inserting new Wi-Fi nodes that are simultaneously connected from as many of the most recently added nodes in the current sequences as possible to the serially connected multipolling sequences that are being constructed, the final serially connected multipolling sequences can be derived that cover the Wi-Fi sensor nodes in the wireless LAN. Applying the aforementioned node insertion algorithm to ten nodes in Figure 2, after inserting nodes 1 and 3 into the first serially connected multipolling sequence, node 2 should be inserted as the next node to the first sequence. Then, nodes 4, 5, 6, 7, 8, 9, and 10 are sequentially inserted, and a single serially connected multipolling sequence (1, 3, 2, 4, 5, 6, 7, 8, 9, 10) that covers ten nodes can be constructed. The pseudocode and the flow chart for implementing the proposed node insertion algorithm are presented in Algorithm 1 and Figure 3, respectively. In Algorithm 1 and Figure 3, the top loop is for selecting the next node, which is a node that is simultaneously connected from as many of the most recently added nodes in the current sequence as possible until the derived multipolling sequences cover all nodes. The second top loop sets the values of \(possibility[i][j]\) at each stage of selecting the next node. \(possibility[i][j]\) is set to 1 if node \(j\) is connected from the previous nodes up to the last (number of sensors in the current multipolling sequence in construction \(-i+1\))\({}^{th}\) node, and \(depth\) is set to the minimal value of \(i\) such that there are one or more \(j\) values satisfying the condition of \(possibility[i][j]=1\). Note that any node \(j\) such that \(possibility[depth][j]=1\) is a node that is simultaneously connected to as many of the most recently added nodes in the current sequence as possible. When applying the proposed node insertion algorithm to the network in Figure 2 to derive the serially connected multipolling sequence (1, 3, 2, 4, 5, 6, 7, 8, 9, 10), the process of setting the \(possibility[i][j]\) values and selecting the next nodes to be inserted into the multipolling sequence during construction is depicted in Figure 4.  
```
for(\(n=1\); \(n\leq\#\) of sensors; \(n++\)) for(\(i=\#\) of sensors in current multipolling seq. ; \(i\geq 1\); \(i\)-) if(\(i=\#\) of sensors in current seq.) \(possibility[i][j]=1\) for all unselected \(j\)'s such that node \(j\) is connected from the previous node; \(possibility[i][j]=0\) for all other \(j\)'s; else \(possibility[i][j]=1\) for all unselected \(j\)'s such that node \(j\) is connected from (\(\#\) of sensors in current seq. \(-i+1\))\({}^{th}\) last node and possibility\([i+1][j]=1\); \(possibility[i][j]=0\) for all other \(j\)'s; if(there is no \(j\) such that possibility\([i][j]=1\)) break and set the \(depth\) to the current stopped value of \(i+1\); if(there is no break in second top loop) set \(depth\) to \(1\); if(current seq. is empty) select any unselected node \(j\) and insert such node \(j\) to the current multipolling seq.