search
Log In
2 votes
673 views

______ to evaluate an expression without any embedded function calls.

  1. Two stacks are required
  2. one stack is needed
  3. Three stacks are required
  4. More than three stacks are required
in DS
retagged by
673 views
0
here what is meaning of embedded function call ???is it more than one function call???
0

Asked from GATE previous year.

https://gateoverflow.in/849/gate2002-2-19

4 Answers

0 votes
Is it option B??
0 votes
One stack is sufficient to evaluate an expression that doesn't have any embedded function calls.
0 votes
Applications of stack are
Converting infix expression into post/prefix expression
Evaluating post/pre-fix expression
Parenthesis matching
With one stack also we can easily evaluate the expression.

Answer-B.One stack is needed
0 votes

The rule is that each function call results in a creation of a stack frame.

When a function call is made, function's arguments are PUSHed on stack. These arguments are further referenced by base pointer.

When the function returns to its caller, the arguments of the returning function are POPed from the stack using LIFO method.

Since there is no function call is embedded, the expression can be evaluated by using only one stack.

Answer:

Related questions

0 votes
3 answers
1
514 views
Evaluation of the given postfix expression $10 \: 10 + 60 \: 6/^*8-$ is $192$ $190$ $110$ $92$
asked Dec 7, 2018 in DS Arjun 514 views
2 votes
1 answer
2
693 views
If we have to construct the expression tree from this expression (3 + ((5+9)*2)) then what will be the order of push and pop operation on a stack ?Explain what to do with each operator and operand along the way of push and pop operation
asked Jul 14, 2016 in DS shekhar chauhan 693 views
0 votes
0 answers
3
225 views
To evaluate an expression with any embedded function call at any time how many stacks are needed?
asked Nov 19, 2017 in Compiler Design iarnav 225 views
0 votes
2 answers
4
603 views
How many stack do we required to evaluate an arithmetic expression? (expression like , 1 + 2 * 3 - 4) One stack is enough Two Stack is needed Number of stack equal to height of tree formed by the expression None of these
asked Nov 17, 2017 in Programming hacker16 603 views
...