Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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: here 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))) + ZStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started