Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

. In C++: Construct the expression tree of slide 14 of week 4 and run FCS eval operation on it (make a C++ adaptation of

. In C++: Construct the expression tree of slide 14 of week 4 and run FCS eval operation on it (make a C++ adaptation of the FCS C code of Figure 5.19). Demonstrate that the outcome is properly computed. Slide 14 shows (1 +2) * (3+4)

fig 5.19:

typedef struct NODE *pNODE; struct NODE { char op; int value; pNODE leftmostChild, rightSibling; }; int eval(pNODE n) { int val1, val2; /* values of first and second subtrees */ if (n->op == 'i') /* n points to a leaf */ return n->value; else { /* n points to an interior node */ val1 = eval(n->leftmostChild); val2 = eval(n->leftmostChild->rightSibling); switch (n->op) { case '+': return val1 + val2; case '-': return val1 - val2; case '*': return val1 * val2; case '/': return val1 / val2; } } }

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

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions