Answered step by step
Verified Expert Solution
Link Copied!

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: image text in transcribedhere 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

More Books

Students also viewed these Databases questions

Question

Describe and apply gestalt perceptual organizing principles?

Answered: 1 week ago