Research Article

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

Algorithm 1

First method.
(1) The position in BP of the first child of the root (ignoring children which belong to the distinct separators)
(2)
(3)
(4) while The position in BP of the rightmostleaf in the tree do
(5)  
(6)  if The node with the position in BP has a terminal edge then
(7)   Add the text position of to where is the parent of the node which has a position in BP
(8) end if
(9)  
(10) end while
(11) firstchild = The position of the first child of the root in BP
(12) for firstchild To rightmostleaf of the tree do
(13)  if isLeaf( ) and ( is a Starting Position in a string ) then
(14)   for 1 to do
(15)    if then
(16)     Sol
(17)    end if
(18)   end for
(19)   Increment by 1 to avoid the closing parenthesis
(20)  else if is an opening parenthesis of an internal node then
(21)   for to size of do
(22)    Push to the corresponding stack
(23)   end for
(24)  else if is a closing parenthesis of an internal node then
(25)   for to size of do
(26)    Pop from the corresponding stack
(27)   end for
(28)  end if
(29) end for