Research Article

Random Secure Comparator Selection Based Privacy-Preserving MAX/MIN Query Processing in Two-Tiered Sensor Networks

Algorithm 2

MaxRSC.
Input: The set of random secure comparators, S
Output: The minimal set of highest secure comparators, Ψ
Procedures:
(1) Initialize , which are used to store type 0 and 1 secure comparators, respectively;
(2) Fetch the first secure comparator from S into the variable a, and set the variable ;
(3) If , add into , otherwise add it into ;
(4) For each ,
   If , then
     If , then add item into ;
     Else
       If , then add item into ;
       Else, delete every if ;
   If , then
     If , then add item into ;
      Else if ,
        then clear , add item into and set flag = 0;
      Else, delete every if ;
   If , then
     If , then add item into ;
     Else
      If , then add item into ;
      Else, delete every if ;
   If , then
     If , then add item into ;
      Else If ,
        then clear , add item into and set flag = 1;
      Else, delete every if ;
End For
(5) If flag = 0, then set Ψ = ; otherwise, set Ψ = ;