their values in further computations. This will require a data structure that will associate variables

The project so far supports calculations on numeric values, but most computational statements (and even most calculators) are not limited to numeric literal values. They usually also include variables. So this assignment will add the ability to assign to variables, and then to later use their values in further computations. This will require a data structure that will associate variables with values, and to do that efficiently, will use a binary search tree. There will be one additional operator for this homework — the sasignment operator (‘=’). We will support the C++ meaning of this operator, that not only assigns to a variable, but ‘computes’ the assigned value. The assignment operator has the lowest precedence (be aware of what that means for the order of calling functions when parsing. Here are a few examples: Special Note: It may be tempting to make the function for assignment operator to be just like the ones for sum and product. That would not be correct, because it would do the operations from left to right. HOWEVER: it can be fixed just by changing the name of one function call within the new while loop. Furthermore, if you do so correctly, the while loop would only repeat 0 or 1 times, so the word ‘while’ could optionally be replaced with a different word. The postfix forms for the legal expres

💡 Buy the answer for only $12 Get it now →

sion would be similar to the other operators: A binary search tree will be used when evaluating the postfix expression. If a variable is the left operand of an assignment, the variable will receive the value. If a variable appears at any other time, its value is retrieved for a computation. That means that the postfix evaluation function’s stack of ‘values’ will now have a mixture of values and variable names, and will need to be able to know the difference and use the information appropriately. HINT: The instructor discovered that if is False. It is safer to check . That will let you more reliably identify whether the stack element is a variable or a number. There is no need for any self-balancing features in this assignment — just the a simple binary tree supporting the ability to store new variables, to associate values with those variables, and to retrieve the value of a variable. For consistency, call your file One new file and three modified files are to appear in the solution to this assignment: You are also encouraged to insert your own unit testing into each file, but that will not be itself graded. Here are a few lines of code from the instructor’s solution and test at this time of writing: You may assume that all expressions are legal C expressions with binary operators, but you may NOT assume that:

💡 Buy the answer for only $12 Get it now →