140 likes | 296 Views
Suffix Trees. ALGGEN: Algorithmics and genetics group Dep. Llenguatges i Sistemes Informàtics Universitat Politècnica de Catalunya. Dr. Xavier Messeguer. http://www.lsi.upc.es/~alggen. Suffix trees. 7: s. s,7. 6: as. s,6. 5: aas. a. a. as,5. as,3. as,3. ba. ba. baas,1.
E N D
Suffix Trees ALGGEN: Algorithmics and genetics group Dep. Llenguatges i Sistemes Informàtics Universitat Politècnica de Catalunya Dr. Xavier Messeguer http://www.lsi.upc.es/~alggen
Suffix trees 7: s s,7 6: as s,6 5: aas a a as,5 as,3 as,3 ba ba baas,1 baas,1 ba ba as,4 as,4 baas,2 baas,2 s,7 s,6 as,5 Given string ababaas: Suffixes: 3: abaas 1: ababaas 4: baas 2: babaas What kind of queries?
Queries on Suffix trees a ba baas,1 ba as,3 baas,2 as,4 s,7 s,6 as,5 • Does the sequence ababaas contain any ocurrence of patterns abab, aab, and ab? ………………………… • Find repeats within the sequence ababaas. …………………………
Insertion algorithm: invariant properties and the suffix-tree …... Given the string …………………………...... P1: the leaves of suffixes from have been inserted P2: the string is the longest string that can be spelt through the tree.
Insertion algorithm: example ababb...,5 a ababb...,3 ba baababb...,1 ba ababb...,4 baababb...,2 Given the string ababaababb...
Insertion algorithm: example Given the string ababaababb... 6 7... ababb...,5 a ababb...,3 ba baababb...,1 ba ababb...,4 baababb...,2
Insertion algorithm: example Given the string ababaababb... 6 7 8... ababb...,5 a ababb...,3 ba baababb...,1 ababb...,4 ba baababb...,2
Insertion algorithm: example Given the string ababaababb... 6 7 8... ababb...,5 a ababb...,3 ba ababb...,1 b baababb...,1 baababb...,1 ababb...,4 ba b...,6 baababb...,2
Insertion algorithm: example Given the string ababaababb... 7 8... ababb...,5 a ababb...,3 ba ababb...,1 b ababb...,4 ba b...,6 baababb...,2
Insertion algorithm: example Given the string ababaababb... 7 8… ababb...,5 a ababb...,3 ba ababb...,1 b ababb...,4 ba b...,6 aababb...,2 b baababb...,2 baababb...,2 b...,7
Insertion algorithm: example a ababb...,1 b b...,6 aababb...,2 b b...,7 Given the string ababaababb... 8… ababb...,5 ababb...,3 ba ababb...,4 ba
Insertion algorithm: improving time Resume: Given the string ababaababb... 6 7 8... a ababb...,5 ababb...,3 ba baababb...,1 ba ababb...,4 baababb...,2 we have pointed to the following nodes
Insertion algorithm: improving time Resume: Given the string ababaababb... 6 7 8... ababb...,5 a ababb...,3 ba baababb...,1 ababb...,4 ba baababb...,2 we have pointed to the following nodes ba baababb...,1 ba baababb...,2
Suffix tree implementation:suffix-links a ba baas,1 ba as,3 baas,2 as,4 s,7 s,6 as,5 Given sequence ababaas a