ALGORITHM: patternGrowth ( )
INPUT: (1) : prefix sequence pattern.
OUTPUT: the set of gap-constrained closed sequential
patterns with prefix .
(14) backward_check (P needPruning, hasBackwardExtension)
(15) if (needPruning)
(16) return;
(17) forward_check( , hasForwardExtension);
(18) if ! (hasBackwardExtension ∣∣ hasForwardExtension)
(19) output pattern ;
(20) search each forward space of all appearances of , and
 find the set of all local frequent items, ;
(21) for each item in
(22) build new pattern = + ;
(23) call patternGrowth ( );
(24) return.
Algorithm 3: Generate closed sequential patterns.