|
Algorithm 1 moving sensors on
|
|
Require: The initial locations of n mobile sensors, placed uniformly and independently at random on the unit interval .
Ensure: The final positions of the sensors such that:
Initialization: Sort the initial locations of n sensors with respect to the origin of the interval, the location of sensors after sorting
-
1:
Let
-
2:
forndo
-
3:
if then
-
4:
move left to right the sensor to the new position
-
5:
else
if
then
-
6:
move right to left the sensor to the new position
-
7:
else
-
8:
do nothing;
-
9:
end if
-
10:
end for
-
11:
ifthen
-
12:
-
13:
for n do
-
14:
move right to left the sensor to the new position
-
15:
end for
-
16:
end if
|