Question: create a function called draw_tree in python that takes a tree at the root and will return the following string: a = buildtree((-x+y)*-(-y+x) print(draw_tree(a)) all

create a function called draw_tree in python that takes a tree at the root and will return the following string:

a = buildtree((-x+y)*-(-y+x)

print(draw_tree(a))

all trees will inherit from the following class:

Here are some example outputs: create a function called draw_tree in python that takes a tree athere is some code i started on that does not work correctly:

def draw_formula_tree(root,level=0): ret = "\t"*level+repr(root._symbol)+" " for child in root._children: ret += draw_formula_tree(child,level+1) return ret

here is my build_tree function: https://pastebin.com/rNyJar95

toopTree(OTree(NTree(Leaf(x')), Leaf ('y')), NTree(OTree (NTree(Leaf ('y')), Leaf("x')))) ((xty)((y+z)* (-y+-z))) + Z toopTree(OTree(NTree(Leaf(x')), Leaf ('y')), NTree(OTree (NTree(Leaf ('y')), Leaf("x')))) ((xty)((y+z)* (-y+-z))) + Z

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!