Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

*Java or C++* The goal of this homework is to build an arithmetic expression TREE (not a stack) for a supplied (hard coded) formula, then

*Java or C++*

The goal of this homework is to build an arithmetic expression TREE (not a stack) for a supplied (hard coded) formula, then traverse the tree to evaluate the expression numerically.

Please use the expression used as an example in slides: A * (B + C) / D

You can use infix, prefix, or postfix notation for the formula. Id suggest using postfix so you can use the tree creation algorithm as described in the slides. The postfix version of the formula is: A B C + * D /

Once you have the tree generated, give the variables integer values for A, B, C, and D, and traverse the tree to calculate the result. There is no need to prompt the user for input, though you can if you want.

For example, if you assign A=2, B=7, C=3, D=5, your result would be 4: 2 * (7 + 3) / 5 = 4

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 A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions

Question

What is the reason behind inflation

Answered: 1 week ago

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago