algorithm - How is worst case time complexity of constructing suffix tree linear? -


i have trouble understanding how worst case time complexity of constructing suffix tree linear - particularly when need build suffix tree string may composed of repeating single character such "aaaaa".

even if construct compressed suffix tree "aaaaa", won't able compress nodes since no 2 edges starting out of node can have string-labels beginning same character.

this result in suffix tree of height 5, , @ each insertion of suffix, need keep traversing root leaf.

here how approached: suffixes: a, aa, aaa, aaaa, aaaaa

create root node, create edge bearing 'a' , connect new node, left bears "$", , repeat process until can aaaaa.

this result in o(n^2) instead of o(n). missing here?

i agree comments, here more details:

the procedure describe forming aaaaa tree o(n), not o(n^2). node , leaf creation constant-time operations, , perform them n==5 times. assumption of o(n^2) seems based on idea you'd traverse root leaf in each step, there no need this; e.g. in ukkonen's algorithm:

  • you keep pointer node left off before inserting next
  • and in case of repetitions don't perform work until repetitions end, , make insertions of final $ mark 1 one, following down characters on edge have created, chain of suffix links in case of more complex repetitions

the key why ukkonen algorithm (details here) o(n) maintains "memory" of make inserts, in form of (a) pointer previous insert made, , (b) network of suffix links. network can vast, there 1 suffix link per internal node, it's still o(n) in size.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -