120
правок
Изменения
Изменен псевдокод
В вершинах дерева <tex>Node</tex> будем хранить следующую информацию:
* <tex>parent</tex> {{---}} предок
* <tex>s[start,\ end]</tex> {{---}} позиции строки, соответствующие ребру до метка подстроки на ребре от предка <tex>s[start, end]</tex>* <tex>length= end - start + 1</tex> {{---}} длина ребра до предка
* <tex>depth</tex> {{---}} глубина вершины в символах
* <tex>suf</tex> {{---}} суффиксная ссылка
Node addSuffix(Node head, '''int''' start):
newHead = slowScan(fastScan(head), start)
'''return''' newHead
Node fastScan(Node head):
'''return''' head
skipped = head.length
curPos = head.start
skipped--
curPos++
curNode = head.parent.suf
curNode = curNode.children[s[curPos]]
skipped -= curNode.length
curPos += curNode.length
'''return''' head.suf
Node slowScan(Node node, '''int''' start):
curNode = node
curPos = start + node.depth
child = curNode.children[s[curPos]]
edgePos = 0
curPos++
edgePos++
curNode = child
'''return''' curNode
</code>
* [http://www.academia.edu/3146231/Algorithms_on_strings_trees_and_sequences_computer_science_and_computational_biology ''Gusfield, Dan'' , Algorithms on Strings, Trees and Sequences: Computer Science and Computational Biology // Cambridge University Press, {{---}} 1999. {{---}} ISBN: 0-521-58519-8]
* [http://users-cs.au.dk/cstorm/courses/StrAlg_f12/slides/suffix-tree-construction.pdf ''C. N. Storm'', McCreight's suffix tree construction algorithm]
== См. также ==