algorithm - Generate all unique substrings for given string -


given string s, fastest method generate set of unique substrings?

example: str = "aba" substrs={"a", "b", "ab", "ba", "aba"}.

the naive algorithm traverse entire string generating substrings in length 1..n in each iteration, yielding o(n^2) upper bound.

is better bound possible?

(this technically homework, pointers-only welcome well)

as other posters have said, there potentially o(n^2) substrings given string, printing them out cannot done faster that. there exists efficient representation of set can constructed in linear time: the suffix tree.


Comments

Popular posts from this blog

android - How to save instance state of selected radiobutton on menu -

python 3 IndexError: list index out of range -

IF statement in MySQL trigger -