searching algorithm

Terry Reedy tjreedy at udel.edu
Thu May 10 23:53:09 EDT 2007


"Neil Cerutti" <horpner at yahoo.com> wrote in message 
news:lNM0i.34412$G23.27437 at newsreading01.news.tds.net...
| Every node is a tuple of its letter, a list of its children, and
| a list of its words. So the two 'pelin' nodes would be (with 'e'
| referenced in the 'h' node):
|
| ('h', [('e', [], ['pelin'])], ['pelin'])
|
| That would in turn be "stored" in the t, n, i and s nodes.
[snip]

At the outer level, I would use a list in order to build the structure in 
pieces, one for each letter, and then add them in.

At the top level, the letters do not need explicit storage.  The first 
subtree is for words starting with 'a', etc.  In other words, the position 
of each subtree indicates its starting letter.  For most letters, this can 
be carried on another level.

tjr






More information about the Python-list mailing list