Page 301 - C++
P. 301
CBSE AISSCE 2016-2017 Marking Scheme for Computer Science
(Sub Code: 083 Paper Code 91 Outside Delhi)
ANS void STACK::PUSHGIFT()
{
GIFT *T = new GIFT;
cin>>T->GCODE;
gets(T->GDESC);
T->Link = TOP;
TOP = T;
}
(1 Mark for creating a new Node)
(1 Mark for fetching values of GCODE and GDESC)
(1 Mark for assigning TOP to the Link of the new Node)
(1 Mark for assigning TOP to the new Node)
NOTE:
GIFT/Gift - Both acceptable
(e) Convert the following Infix expression to its equivalent Postfix expression, showing 2
the stack contents for each step of conversion:
X - ( Y + Z ) / U * V
Ans
ELEMENT Stack POSTFIX
X X
- - X
( -( X
Y -( XY
+ -(+ XY
Z -(+ XYZ
) - XYZ+
/ -/ XYZ+
U -/ XYZ+U
* -* XYZ+U/
V -* XYZ+U/V
XYZ+U/V*-
OR
X-(Y+Z)/U*V = (X-(((Y+Z)/U)*V))
ELEMENT Stack POSTFIX
(
X X
- -
(
(
(
Y XY
+ - +
Z XYZ
) - XYZ+
/ -/
U XYZ+U
Page #11 of 28