private void Bide()
        {
            _allSequentialPatterns.Clear();

            ProjectedDatabase projectedDatabase = _sequenceDatabase.ConvertToProjectedDatabase();

            // Divides the search space according to frequent items and mine each recursively.
            for (int i = 0; i < _1LengthSequentialPatterns.Count; ++i)
            {
                ProjectedDatabase freqItemProjectedDb = ConstructProjectedDatabase(_1LengthSequentialPatterns[i], projectedDatabase);

                if (freqItemProjectedDb == null || !freqItemProjectedDb.IsNotEmpty)
                {
                    continue;
                }

                if (ClosureChecker.BackScan(freqItemProjectedDb))
                {
                    PrunedSequencesCount++;
                }
                else
                {
                    Bide(freqItemProjectedDb);
                }
            }
        }
        private void Bide(ProjectedDatabase projectedDatabase)
        {
            if (Stopped)
            {
                return;
            }

            _sExtensions.Clear();
            _iExtensions.Clear();

            // Scans projected database once and finds extension items.
            projectedDatabase.FindLocalFrequentItems(_minSupport, _sExtensions, _iExtensions);

            var newSequentialPatterns = new List <Sequence>();

            // Sequence-extension items.
            foreach (var pair in _sExtensions.OrderBy(e => e.Key))
            {
                newSequentialPatterns.Add(
                    Sequence.CreateNewBySStep(projectedDatabase.Prefix, pair.Key, pair.Value));
            }

            // Itemset-extension items.
            foreach (var pair in _iExtensions.OrderBy(e => e.Key))
            {
                newSequentialPatterns.Add(
                    Sequence.CreateNewByIStep(projectedDatabase.Prefix, pair.Key, pair.Value));
            }

            // If projected database does not contain backward or forward extensions
            // than a prefix of projection is closed sequential pattern.
            if (!HasProjectedDatabaseAnyExtensions(projectedDatabase, newSequentialPatterns))
            {
                _allSequentialPatterns.Add(projectedDatabase.Prefix);

                LogPattern(projectedDatabase.Prefix);
            }
            else
            {
                NoClosedSequencesCount++;
            }

            // Divides the search space and recursively mine the subset of all sequential patterns.
            for (int i = 0; i < newSequentialPatterns.Count; ++i)
            {
                ProjectedDatabase seqPatternProjectedDatabase = ConstructProjectedDatabase(newSequentialPatterns[i], projectedDatabase);

                if (seqPatternProjectedDatabase == null || !seqPatternProjectedDatabase.IsNotEmpty)
                {
                    continue;
                }

                if (ClosureChecker.BackScan(seqPatternProjectedDatabase))
                {
                    PrunedSequencesCount++;
                }
                else
                {
                    Bide(seqPatternProjectedDatabase);
                }
            }
        }