in DS retagged by
2,099 views
5 votes
5 votes

______ 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
by
2.1k views

2 Comments

here what is meaning of embedded function call ???is it more than one function call???
0
0

Asked from GATE previous year.

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

1
1

5 Answers

1 vote
1 vote
Is it option B??
1 vote
1 vote
One stack is sufficient to evaluate an expression that doesn't have any embedded function calls.
1 vote
1 vote
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
1 vote
1 vote

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.