Question

Evaluate the following postfix expression: 6 4 + 3 10 * 2 2 2 - +...

Evaluate the following postfix expression: 6 4 + 3 10 * 2 2 2 - + * +

What is the highest number of elements on our stack at any one time?

can you please explain the answer for me ?

Homework Answers

Answer #1
6 4 + 3 10 * 2 2 2 - + * +
--------------------------------
stack: []
push 6
stack: [6]
push 4
stack: [6 4]
pop, 6 and 4, push 6+4 = 10
stack: [10]
push 3
stack: [10 3]
push 10
stack: [10 3 10]
pop, 3 and 10, push 3*10 = 30
stack: [10 30]
push 2
stack: [10 30 2]
push 2
stack: [10 30 2 2]
push 2
stack: [10 30 2 2 2]
pop, 2 and 2, push 2-2 = 0
stack: [10 30 2 0]
pop, 2 and 0, push 2+0 = 2
stack: [10 30 2]
pop, 30 and 2, push 30*2 = 60
stack: [10 60]
pop, 10 and 60, push 10+60 = 70
stack: [70]

value of this expression is 70
and we can see that maximum size of stack is 5
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
(For Python) Evaluating Postfix Arithmetic Expressions. In this project you are to implement a Postfix Expression...
(For Python) Evaluating Postfix Arithmetic Expressions. In this project you are to implement a Postfix Expression Evaluator as described in section 7-3b of the book. The program should ask the user for a string that contains a Postfix Expression. It should then use the string's split function to create a list with each token in the expression stored as items in the list. Now, using either the stack classes from 7.2 or using the simulated stack functionality available in a...
Find is the final result of evaluating the following postfix expression using a stack. Show each...
Find is the final result of evaluating the following postfix expression using a stack. Show each push and pop operation. 85 5 / 4 * 5   6 +   10    5 -   * +
in Java In this exercise, you'll write a Java version of the infix-to-postfix conversion algorithm. These...
in Java In this exercise, you'll write a Java version of the infix-to-postfix conversion algorithm. These same mechanisms can be used as a part of writing a simple compiler. Write class InfixToPostfixConverter co convert an ordinary infix arithmetic expression (assume a valid expression is entered) with single-digit integers (to make things easier) such as (6 + 2) • 5 - 8 / 4 to a postfix expression. The postfix version (no parentheses are needed) of this infix expression is 6...
Python The final value of the evaluation of the postfix expression 6 2 + 5 *...
Python The final value of the evaluation of the postfix expression 6 2 + 5 * 8 4 / - is ----------
Please give the postfix form of the arithmetic expression (a*b + 2*c)/(2 - 3*d) + c
Please give the postfix form of the arithmetic expression (a*b + 2*c)/(2 - 3*d) + c
python Given: x = 3 y = 2 Evaluate the following expression to a single numeric...
python Given: x = 3 y = 2 Evaluate the following expression to a single numeric answer: (x + y) // x Step 1) Substitute in the values Step 2) Perform the operation of highest precedence Step 3) Final answer
4) Suppose the memory of a computer is as follows: Address 0x100 Address 0x101 Address 0x102...
4) Suppose the memory of a computer is as follows: Address 0x100 Address 0x101 Address 0x102 Address 0x103 12 34 56 78 What integer value is this on a big-endian computer? 5) Use a stack to evaluate the postfix expression: 6 3 * 5 3 - /
Java Please [(1)] A palindrome is a string that reads the same forwards as backwards. Using...
Java Please [(1)] A palindrome is a string that reads the same forwards as backwards. Using only a fixed number of stacks and queues, the stack and queue ADT functions, and a fixed number of int and char variables, write an algorithm to determine if a string is a palindrome. Assume that the string is read from standard input one character at a time. The algorithm should output true or false as appropriate [(2)] Let Q be a non-empty queue,...
1.You evaluate an indefinite integral and obtain the following expression for an answer 1/5 sin(1+5x) +...
1.You evaluate an indefinite integral and obtain the following expression for an answer 1/5 sin(1+5x) + C. What was the integrand of the indefinite integral that you evaluated? 2.You evaluate an indefinite integral and obtain the following expression for an answer: -1/4(x^4 - 5) + C. What was the integrand of the indefinite integral that you evaluated?
Evaluate C(11,4). C(11,4) equals = Six cards are marked with the numbers 1, 2, 3, 4,...
Evaluate C(11,4). C(11,4) equals = Six cards are marked with the numbers 1, 2, 3, 4, 5, and 6 , then shuffled, and three cards are drawn. a. How many different three -card combinations are possible? b. How many three -card hands contain a number less than three? Use a tree diagram for the following. a. Find the number of ways 2 letters can be chosen from the set {U, V, W, X} if order is important and repetition is...