Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  To evaluate an expression without any embedde... Start Learning for Free
To evaluate an expression without any embedded function calls
  • a)
    One stack is enough
  • b)
    Two stacks are needed
  • c)
    As many stacks as the height of the expression tree are needed
  • d)
    A Turing machine is needed in the general case
Correct answer is option 'A'. Can you explain this answer?
Verified Answer
To evaluate an expression without any embedded function callsa)One sta...
Any expression can be converted into Postfix or Prefix form.

Prefix and postfix evaluation can be done using a single stack.

For example : Expression ’10 2 8 * + 3 -‘ is given.
PUSH 10 in the stack.
PUSH 2 in the stack.
PUSH 8 in the stack.
When operator ‘*’ occurs, POP 2 and 8 from the stack.
PUSH 2 * 8 = 16 in the stack.
When operator ‘+’ occurs, POP 16 and 10 from the stack.
PUSH 10 * 16 = 26 in the stack.
PUSH 3 in the stack.
When operator ‘-‘ occurs, POP 26 and 3 from the stack.
PUSH 26 – 3 = 23 in the stack.
So, 23 is the answer obtained using single stack.

 
Thus, option (A) is correct.
View all questions of this test
Most Upvoted Answer
To evaluate an expression without any embedded function callsa)One sta...
Explanation:

To evaluate an expression without any embedded function calls, one stack is enough. This is because the expression can be evaluated using a simple stack-based algorithm that follows the rules of postfix notation.

Postfix notation, also known as Reverse Polish notation, is a way of writing mathematical expressions in which the operator comes after the operands. For example, the expression 3 + 4 would be written as 3 4 + in postfix notation.

The algorithm for evaluating a postfix expression using a single stack is as follows:

1. Initialize an empty stack.
2. Scan the expression from left to right.
3. If the current token is an operand, push it onto the stack.
4. If the current token is an operator, pop the top two operands from the stack, apply the operator to them, and push the result back onto the stack.
5. When the expression has been fully scanned, the result is the top element of the stack.

Using this algorithm, any postfix expression can be evaluated using a single stack. There is no need for multiple stacks or a Turing machine.

In summary, to evaluate an expression without any embedded function calls, one stack is enough using the postfix notation algorithm.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Question Description
To evaluate an expression without any embedded function callsa)One stack is enoughb)Two stacks are neededc)As many stacks as the height of the expression tree are neededd)A Turing machine is needed in the general caseCorrect answer is option 'A'. Can you explain this answer? for Computer Science Engineering (CSE) 2025 is part of Computer Science Engineering (CSE) preparation. The Question and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus. Information about To evaluate an expression without any embedded function callsa)One stack is enoughb)Two stacks are neededc)As many stacks as the height of the expression tree are neededd)A Turing machine is needed in the general caseCorrect answer is option 'A'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2025 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for To evaluate an expression without any embedded function callsa)One stack is enoughb)Two stacks are neededc)As many stacks as the height of the expression tree are neededd)A Turing machine is needed in the general caseCorrect answer is option 'A'. Can you explain this answer?.
Solutions for To evaluate an expression without any embedded function callsa)One stack is enoughb)Two stacks are neededc)As many stacks as the height of the expression tree are neededd)A Turing machine is needed in the general caseCorrect answer is option 'A'. Can you explain this answer? in English & in Hindi are available as part of our courses for Computer Science Engineering (CSE). Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.
Here you can find the meaning of To evaluate an expression without any embedded function callsa)One stack is enoughb)Two stacks are neededc)As many stacks as the height of the expression tree are neededd)A Turing machine is needed in the general caseCorrect answer is option 'A'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of To evaluate an expression without any embedded function callsa)One stack is enoughb)Two stacks are neededc)As many stacks as the height of the expression tree are neededd)A Turing machine is needed in the general caseCorrect answer is option 'A'. Can you explain this answer?, a detailed solution for To evaluate an expression without any embedded function callsa)One stack is enoughb)Two stacks are neededc)As many stacks as the height of the expression tree are neededd)A Turing machine is needed in the general caseCorrect answer is option 'A'. Can you explain this answer? has been provided alongside types of To evaluate an expression without any embedded function callsa)One stack is enoughb)Two stacks are neededc)As many stacks as the height of the expression tree are neededd)A Turing machine is needed in the general caseCorrect answer is option 'A'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice To evaluate an expression without any embedded function callsa)One stack is enoughb)Two stacks are neededc)As many stacks as the height of the expression tree are neededd)A Turing machine is needed in the general caseCorrect answer is option 'A'. Can you explain this answer? tests, examples and also practice Computer Science Engineering (CSE) tests.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev