Supersequence from a string bag

Given string s, what is the most efficient way to determine the shortest supersymmetry s from a string bag? In addition, the last character s must match the last character of the super string.

+5
source share
3 answers

If I did not understand it, this problem is definitely in P.

Naive approach:

  • Take all the lines in B ending with the same character as s. Name this new package B '. Can be done in O (| B |)
  • , s B '.   O (| B '| * max (| z |)) z B. , s z, O (| z |)
  • ( O (| B '|))

| x | x.

, O (| B | * max (| z |)) .

+2

, , DAWG A *.

+1

, , s , , KMP. , . O(Σlength of strings in bag).

, trie . O(|s|).

0

All Articles