# NIELIT 2018-54

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
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

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

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.

## Related questions

1
514 views
Evaluation of the given postfix expression $10 \: 10 + 60 \: 6/^*8-$ is $192$ $190$ $110$ $92$