Exemplo n.º 1
0
        res1 = None
        res2 = None

        if build_parse_tree != None #or if build_parse_tree:
            res1 = postOrderEval(build_parse_tree.get_left_child())
            res2 = postOrderEval(build_parse_tree.get_right_child())

            if res1 and res2:
                return opers[build_parse_tree.get_root_val()](res1, res2)
            else:
                return build_parse_tree.get_root_val()
            
        


                
tree = BinaryTree('')
tree.set_root_value('+')
tree.insert_left(3)
t = tree.insert_right('*')
t.insert_left(4)
t.insert_right(5)

pt = build_parse_tree(tree)
print(pt.postOrderEval())