Exemplo n.º 1
0
#    tr2 = tree_factory([4,5,6,7])
# NameError: name 'tree_factory' is not defined

##########################################################
# Define a function treeGenerator that generate all possible trees with n nodes.
# Use python generators as part of your solution.  Note that CLU iterators are
# what python calls generators.
# See section 2.2 of Advanced Programming Language Design
#     for example in CLU
# http://www.nondot.org/sabre/Mirrored/AdvProgLangDesign/finkel00.pdf
# or ftp://ftp.aw.com/cseng/authors/finkel/apld/
# e.g.  trees are all possible trees with 3 nodes.
"""
tree_generator is implemented in TreeModule.py
"""
prettyPrint(TreeModule.tree_generator(3))

#Why are there 2 parameters???
# >>> trees = treeGenerator(1,3)
# >>> prettyPrint(trees)
#Tree: 1
#    2
#  1
#0
#
#Tree: 2
#  1
#    2
#0

#Tree: 3