## 7 SMEP Algorithms
### AuxDataQueue Compression Algorithm
Then, the new last sensor data value and its absolute position in the last zone are newly recorded into _ZoneCompHistory[m \(-\) 1,c+1]_ for the next compressions (procedure line 22), where c is the number of the last compression in the last zone before calling this procedure. ### Consecutive Equivalent Zones Compression Algorithm

Let us say that the zones are _equivalent_ when zones are same in numbers of compressions. _EquivalentZonesCompression_ is a procedure that compresses the consecutive zones equivalent with the last zone, and that keeps _Rule 2 (i)_ and (ii)_ in the _Zones operations_ definition (Definition 20). This procedure also returns to the _SMEP_ main procedure the value and absolute position of the last selected sensor data, where this sensor data is the last of the beginning zone among consecutive equivalent zones after compressing their sensor data. The _SMEP_ main procedure calls this procedure to pass the beginning zone among consecutive equivalent zones to the parameter _StartZone_, as shown in the Algorithm 3. _DQGP_ is calculated as the greatest position (index) among _DataQueue_ positions (indices) covered by zones before the _StartZone_ zone. This position is used to calculate _DataQueue_ positions of sensor data in _DataQueue_ from the _StartZone_ zone to the last \(m-\) 1_ zone (procedure line 2). In fact, a sensor data sequence from the _StartZone_ zone to the last zone is the same as the sensor data sequence from _DataQueue[DQGP+1]_ to _DataQueue[2\({}^{m}\)]_. At this time, if _StartZone_ is not zero, the _ZoneCompHistory[StartZone, c].Value_ is used as a base sensor data and _ZoneCompHistory[StartZone, c]. Position_ is used as its absolute position (procedure line 4). The compression proceeds over the 2-size compression interval covering on this sensor data sequence (from procedure line 4 to line 11). In this compression, the procedure applies alternately the _selection by pattern_ rule and the _selection by minimum error_ rule for the odd number intervals and the even number intervals, respectively (procedure line 6 and line 7). Here, _DQGP_ is used to calculate the _DataQueue_ position to save the sensor data selected for each interval (procedure line 8 and line 9). The sensor data sequence from the _StartZone_ zone to the last \(m-\) 1 zone is compressed to the _Startzone_ zone, where this is proved in the last of this section. Additionally, the zone bit sequence about the _StartZone_ zone is generated during compression using I-bit positions of \(S_{c,p}\) and \(S_{c,j}\) and the zone bit strings corresponding to them (procedure line 10 and line 12). The procedure calculates the absolute position of the last selected sensor data in the compression using _Zones[StartZone]_ and _ZoneBySeq[StartZone]_ according to the Theorem 8 (procedure line 13), and returns this last sensor data value and absolute position which are to be saved to _ZoneCompHistory[StartZone, Zones[StartZone] + 1]_ by the _SMEP_ main procedure. Finally, we prove the below theorem (For the proof refer to Appendix G):

**Theorem 9**. : _In the compression for the sensor data sequence in consecutive equivalent zones from the StartZone zone to the last \(m-\) 1 zone in DataQueue, this sensor data sequence is compressed to the _Startzone zone_. ### Main Algorithm

The SMEP main procedure proceeds to save and compress the growing ground sensor data sequence controlling _Zones operations Rule 1_ and _Rule 2_ in the Definition 20 in Section 6.1. This procedure uses the data structures and procedures already introduced in previous sections. This algorithm is illustrated in Algorithm 4. At first, the produce initializes _Zones_ and _ZoneCompHistory_ data structures, the absolute position variable _Ap_, the _DataQueue_ index _DQinx_ and the zone index variable _ZNinx_ (from procedure line 1 to line 7). Then, the procedure reads and inserts a ground sensor data into _DataQueue_ (procedure line 9 and line 10).