Research Article

Escaping Depressions in LRTS Based on Incremental Refinement of Encoded Quad-Trees

Algorithm 3

Pseudocode of the algorithm to repair and query a node.
(1) RepairANode(, NewState)
(2) if   in the hash table then
(3)  if   is a leaf node then
(4)   .state = NewState;
(5)    .parent;
(6)   while all children of possess the same
     state do
(7)    erase all the children from the table;
(8)    .state NewState, .parent;
(9)    if   is the root node then
(10)     break the while loop;
(11)    end
(12)   end
(13)  else
(14)   .state = NewState;
(15)   for each .child do
(16)    ClearSubTree();
(17)   end
(18)  end
(19) else
(20)  CreateANode(, NewState);
(21) end
(22) ClearSubTree()
(23) if   is not a leaf node then
(24)  for each child do
(25)   ClearSubTree();
(26)  end
(27) else
(28)  erase from the table;
(29) end
(30) CreateANode(, NewState)
(31) ;
(32) while   not in the table and not the root node do
(33)  parent;
(34) end
(35) if    then
(36)  .child new 4 leaf nodes, ;
(37)  for each child do
(38)   if   is an ancestor of or   then
(39)    state = grey;
(40)   else
(41)    state state;
(42)   end
(43)  end
(44) end
(45) state = NewState;
(46) QueryANode()
(47) while   not in the table and not the root node do
(48)  .state;
(49) end
(50) return state;