Aspire's Library

A Place for Latest Exam wise Questions, Videos, Previous Year Papers,
Study Stuff for MCA Examinations - NIMCET

Previous Year Question (PYQs)



Consider the following postfix expression with single-digit operands:

$6\ 2\ 3\ *\ /\ 4\ 2\ *\ +\ 6\ 8\ *\ -$

The top two elements of the stack after the second $*$ is evaluated, are:






Solution

Given postfix expression is

$6\ 2\ 3\ *\ /\ 4\ 2\ *\ +\ 6\ 8\ *\ -$

First, push $6,2,3$ into stack.

After first $*$:

$2*3=6$

Stack becomes

$6,6$

Now, apply $/$:

$6/6=1$

Stack becomes

$1$

Now, push $4$ and $2$.

Stack becomes

$1,4,2$

Now, second $*$ is evaluated:

$4*2=8$

Stack becomes

$1,8$

So, the top two elements are

$8,1$



Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More


Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More

Ask Your Question or Put Your Review.

loading...