1. Variable Initialization (K: Sensor node; Δt: Task; µ: Idle state; St: Synchronization time; Is: Idle state; Δtc: Total tasks & Os: Off state)

2. Input: (: Initial energy of sensor node;: Consumed energy in idle state)

3. Output: (: Sensor node lifetime)

4. For (;;)

5. Compute Δt

6. If K completes Δt then

7. K = µ // Sensor node goes to idle state temporarily to check its next task

8. // Sensor node checks its next synchronization time

9. Swamping // Sensor node goes from idle state to sleep state

10. Else if // Sensor node needs to continue task

11. End if

12. End if

13. Calculate // Lifetime of sensor node based on energy

14. For end