Question: You will need to use a stack in both your convert() function and in your evaluate() function. If you look at the algorithm to convert
You will need to use a stack in both your convert() function and in your evaluate() function. If you look at the algorithm to convert infix to postfix you will note that you never use the stack to store operands (variables or constants). You only use the stack to store operators or '(', which are always single characters. Recall that a character is just a number that can be saved in a stack designed to hold only integers. Since the eval() function only stores integers in the stack, and since you can store characters as integers in the stack in your convert() function, the new version of mystack will work for both functions.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
