> i am trying to understand this code: > http://nbviewer.ipython.org/gist/BenLangmead/6665861
I'm slightly familiar with the purpose of the code. It's constructing a Suffix Tree, though not in linear time. Reading the code... ah. I see. This is enumerating through all suffixes, and building it by repeated insertion into a trie. http://en.wikipedia.org/wiki/Trie The classes are used here to represent structured data and operations to be performed on that structured data. The code fundamentally has a structured value called a Node, with two fields to represent the string label and the links to other nodes. Aside: there is a very good book by Dan Gusfield that talks about suffix trees and how to construct them called "Algorithms on Strings, Trees and Sequences: Computer Science and Computational Biology" http://www.amazon.com/Algorithms-Strings-Trees-Sequences-Computational/dp/0521585198 which you may want to look at if you're interested in these algorithms. It is probably not a good idea to try to intermix trying to understand an algorithm like this at the same time as you're learning basic features in your programming language. Consider a slightly simpler example to learn about "classes", apart from the algorithms you are studying. Most good Python tutorials should cover how to use classes to build structured data and manipulate it. Alan Gauld's Python tutorial, for example, should have a section on this. http://www.alan-g.me.uk/tutor/tutclass.htm _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor