Research Article

Recommending Locations Based on Users’ Periodic Behaviors

Algorithm 2

Generating matrix.
Input: S(time sequence)
  ts (target state)
Output: matrix (the suspected periods stored matrix)
  map (hash mapping relation)
  T (the time stamps the target state happened)
begin:
(1) map = new HashMap (key, value) // hash mapping relation between time stamps and the
number of the row and column in the matrix
(2) // the time stamps the target state happened
(3) // the number of the row in the matrix
(4)
(5)  While   do
(6)   if  [ ] == ts do
(7)     map.put
(8)     
(9)     
(10)     T.append( )
(11)   end
(12)   
(13) end
(14) matrix = int[r + 1][r + 1]
(15) for t1 in T do
(16)   for t2 in T do
(17)     sp = t2–t1//suspected periods
(18)    if  sp > 0  and  sp < len(S)/2  do
(19)    matrix[map.get(t1)][map.get(t2)] = sp
(20)    end
(21)   end
(22) end
(23) return  matrix, map, T
end