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 - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -