Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(1) (50%) Write a C program! that takes as input a fully parenthesized, arithmietic expression of binary operators +, -, *, /, and converts the

image text in transcribed

(1) (50%) Write a C program! that takes as input a fully parenthesized, arithmietic expression of binary operators +, -, *, /, and converts the expression into a binary expression tree. Your program should take input from the command line. The entire expression should be in a character string without any space in it An input string only includes floating numbers in the format of Y.YY, that is, one digit to the left of the decimal point and two digits to the right of the decimal point, and variables of the form of x1, x2, Your program shall allow for the leaves in the expression tree not only to store floating values but also to store variables of the form x1, x2, X3, , which are initially 0.0 and can be updated interactively by the user. For example, expression (15.12)*(r2- 7.68)/r3) will be converted into a binary expression tree like: x1 5.12 x2 7.68 Your program should then show a menu with the following options 1. Display 2. Preorder 3. Inorder 4. Postorder 5. Update 6. Calculate 7. Exit Description . When option 1 is selected, your program should display the tree in some way so that the tree can be visualized, and also print the name and value of each variable, like "X1:0.0" when x1 initially has value 0.0 If an option of 2, 3 or 4 is selected, your program should print the expression by the corresponding traversal order (Note: no parentheses for preorder and postorder traversal but fully parenthesized for inorder traversal) Option 5 requires further input froin user. A pair of input, namely variable name, new-value will be provided interactively and your program should search for the variable.name and replace its value by new value Arithmetic calculation is invoked by option 6 which shall display the calculation result Your program should be able to detect an error of divide-by-zero before calculation

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

More Books

Students also viewed these Databases questions

Question

ctionf (x)=(3)/(x+2)+ 1. Con er. Use the left and right a

Answered: 1 week ago

Question

List the characteristics of an effective HR strategy.

Answered: 1 week ago

Question

Prepare an ID card of the continent Antarctica?

Answered: 1 week ago

Question

3. What strategies might you use?

Answered: 1 week ago

Question

3. Write a policy statement to address these issues.

Answered: 1 week ago