Research Article

Using the Sadakane Compressed Suffix Tree to Solve the All-Pairs Suffix-Prefix Problem

Algorithm 2

Second method.
(1) The position of the first child of the root in BP (ignoring children which belong to the distinct separators)
(2)
(3)
(4)
(5) for (BP position of the leaf with rank ) To (BP position of the rightmost leaf) do
(6)  if the text position of is a starting position of the string then
(7)   for to do
(8)    if then
(9)     Sol[ ] = top(stack( ))
(10)   end if
(11)  end for
(12)  if is less than BP position of the rightmost leaf then
(13)    is BP position of the node which is next to the one indicated by in BP
(14)   while and have a terminal edge, and the same parent do
(15)     is the string to which the text position of belongs
(16)     is the string to which the text position of belongs
(17)    Sol The ending position of the text position of
(18)    
(19)   end while
(20)  end if
(21)  end if
(22) if is less than BP position of the rightmost leaf then
(23)  if LCP( ) < LCP( ) then
(24)   while > LCP( ) do
(25)     is the top of
(26)    for each element in the list do
(27)     Pop the stack[ ])
(28)     Pop l[ ]
(29)    end for
(30)     )
(31)   end while
(32)  else if has a terminal edge then
(33)    is BP position of the node which is next to the one indicated by in BP
(34)   if and have the same parent then
(35)     is the string to which the text position of belongs
(36)    Push(Stack[ ], Ending position of Text position of )
(37)    Push( , )
(38)    if then
(39)     Push( )
(40)    end if
(41)    end if
(42)  end if
(43) end if
(44) 
(45) 
(46) end for