[Type B] Chapter – 10 Class 12 CS – Sumita Arora Assignment | Q/A

Here is class 12 computer science Unit 10 [Section B] solutions for Sumita Arora back exercise assignment. Below includes both textual and video solutions wherever required. View all the answers in assignment for chapter 10 and for all chapters here.

Watch all tutorials for chapter 10.

Q1: Translate following infix expression into its equivalent postfix expression:
( (A-B)*(D/E)/(F*G*H)
Input String = ((A-B)*(D/E))/(F*G*H)
Output StackOperator Stack
((
A((
A((-
AB((-
AB-(
AB-(*
AB-(*(
AB-D(*(
AB-D(*( /
AB-DE(*( /
AB-DE/*
AB-DE/*/(
AB-DE/*F/(
AB-DE/*F/(*
AB-DE/*FG/(*
AB-DE/*FG/(*
AB-DE/*FG*H/(*
AB-DE/*FG*H*/
Q2: Translate following infix expression into its equivalent postfix expression :
(A+B↑D)/(E-F)+G
Input String = (A+B^D)/(E-F)+G
OUTPUT STACKOPERATION STACK
(
A(
A(+
AB(+
AB (+^
ABD(+^
ABD^+
ABD^+/(
ABD^+E/(
ABD^+E/(-
ABD^+EF/(-
ABD^+EF-/
ABD^+EF-/+
ABD^+EF-/G+
ABD^+EF-/G+
Q3: Translate following infix expression into its equivalent postfix expression :
A*(B+D)/E-F-(G+H/K)
Input String = A*(B+D)/E-F-(G+H/K)
Expression StackOperatorStack
A
A*
A*(
AB*(
AB*(+
ABD*(+
ABD+*
ABD+*/
ABD+*E/
ABD+*E/
ABD+*E/F
ABD+*E/F-
ABD+*E/F--(
ABD+*E/F-G-(+
ABD+*E/F-GH-(+
ABD+*E/F-GH-(+/
ABD+*E/F-GHK-(+/
ABD+*E/F-GHK/+
ABD+*E/F-GHK/+-
Q4: Write the equivalent infix expression for 
10,3,*,7,1,-,*,23,+

Stack
10
3
10
10*3
7
10*3
1
7
10*3
7-1
10*3
(10*3)*(7-1)
2
(10*3)*(7-1)
3
2
(10*3)*(7-1)
Q5: Write the equivalent infix expression for a,b,AND,a,c,AND,OR

Stack
a
b
a
a AND b
a
a AND b
c
a
a AND b
a AND c
a AND b
(a AND b) or (a AND b)
Q6: Consider the arithmetic expression P, written in postfix notation:
12,7,3,-,/,2,1,5,+,*,+
(a) Translate P, into its equivalent infix expression.
(b) Evaluate the infix expression.

Stack
12
7
12
3
7
12
7-3
12
12/(7-3)
2
12/(7-3)
1
2
12/(7-3)
5
1
2
12/(7-3)
1+5
2
12/(7-3)
2*(1+5)
12/(7-3)
12/(7-3) + (2*(1+5))
Solved = 15
Q7: Convert the following infix notation of expression to an equivalent postfix notation of expression (Show status of the stack after the execution of each operation) :(A+B)*C-D / E
Input string: (A+B)*C-D / E
StackOperator
(
A(+
AB(+
AB+
AB+*
AB+C*
AB+C*
AB+C*D
AB+C*D-/
AB+C*DE-/
AB+C*DE/-
Q8: Consider each of the following postfix expressions:
P1: 5,3,+,2,*,6,9,7,-,/-
P2: 3,5,+,6,4,-,*,4,1,-,2,↑,+
P3:3,1,+,2,↑,7,4,-,2,*,+,5,-
Translate each expression into infix notation and then evaluate
Input expression = 5,3,+,2,*,6,9,7,-,/-
5
3
5
5+3
2
5+3
(5+3)*2
7
9
6
(5+3)*2
9-7
6
(5+3)*2
6/(9-7)
(5+3)*2
(5+3)*2 – 6/(9-7)
Result = 13
P2: 3,5,+,6,4,-,*,4,1,-,2,↑,+
5
3
3+5
4
6
3+5
6-4
3+5
(3+5)*(6-4)
1
4
(3+5)*(6-4)
4-1
(3+5)*(6-4)
2
4-1
(3+5)*(6-4)
(4-1)^2
(3+5)*(6-4)
(3+5)*(6-4) + (4-1)^2
result = 25
P3 : 3,1,+,2,↑,7,4,-,2,*,+,5,-
1
3
3+1
2
3+1
(3+1)^2
4
7
(3+1)^2
7-4
(3+1)^2
2
7-4
(3+1)^2
(7-4)*2
(3+1)^2
(3+1)^2 + (7-4)*2
5
(3+1)^2 + (7-4)*2
(3+1)^2 + (7-4)*2 – 5
Result = 17
Q9: Give postfix form of the following expression :
A*(B+(C+D)*(E+F) /G)*H
Input String = A*(B+(C+D)*(E+F) /G)*H
StackOperator
A*
AB*(
AB*(+
AB*(+(
ABC*(+(+
ABCD+*(+
ABCD+*(+*
ABCD+E*(+*(
ABCD+EF*(+*(+
ABCD+EF+*(+*
ABCD+EF+**(+/
ABCD+EF+*G*(+/
ABCD+EF+*G/+*(*
ABCD+EF+*G/+*H*
Q10: Give postfix form for A+{ (B+C)+(D+E)*F}/G
Input string = A+{(B+C)+(D+E)*F}/G
StackOperator
A+{(
AB+{(
AB+{(+
ABC+{(+
ABC++{
ABC++{+(
ABC+D+{+(
ABC+D+{+(+
ABC+DE++{+
ABC+DE++{+*
ABC+DE+F+{+*
ABC+DE+F*++
ABC+DE+F*+G+/
ABC+DE+F*+G/+
Q11: Give postfix form of expression for the following
(i) NOT A OR NOT B AND NOT C
(ii)NOT (A OR B) AND C
Order  NOT>AND>OR
(i) NOT A OR NOT B AND NOT C
Stackoperator
NOT
AOR
A NOTOR
A NOT B OR NOT
A NOT B NOTOR AND
A NOT B NOTOR AND NOT
A NOT B NOT COR AND NOT
A NOT B NOT C NOT AND OR
(ii)NOT (A OR B) AND C
StackOperator
NOT
NOT (
ANOT ( OR
A BNOT ( OR
A B ORNOT
A B ORAND
A B OR NOTAND
A B OR NOT CAND
A B OR NOT C AND
Q12: Evaluate the following postfix notation of expression:
True, False, NOT, AND, True, True, AND, OR
Order NOT>AND>OR
True
False
True
Not False
True
True AND (NOT False)
True
True AND (NOT False)
True
True
True AND (NOT False)
True AND True
True AND (NOT False)
(True AND (NOT False)) OR (True AND True)
Output : True
Q13: Evaluate the following postfix expression using a stack and show the contents of the stack after execution of each operation 5,11, -,6,8,+,12,*, /
5,11, -,6,8,+,12,*, /
5
11
5
5-11
6
5-11
8
6
5-11
6+8
5-11
12
6+8
5-11
(6+8)*12
5-11
(5-11) / ((6+8)*12)
ans = -1/28
Q14: Let P be the postfix arithmetic expression : 7,2,-,1,14,-,1,2,* Evaluate P using stack and showing the status of the stack at every step.
7,2,-,1,14,-,1,2,*

Incomplete question for the final evaluation as operator are missing.
Q15: Consider the infix expression:
Q:A+B*C↑(D/E)/F.
Translate Q into P, where P is the postfix equivalent expression of Q, what will be the result of Q if this expression is evaluated for A,B,C,D,E,F as 2,3,2,7,2,2 respectively.
Q : A+B*C^(D/E)/F
StackOperator
A
A+
AB+
AB+*
ABC+*
ABC+*^
ABC+*^(
ABCD+*^( /
ABCDE+*^( /
ABCDE/+*^
ABCDE/^*+/
ABCDE/^*F/+
A,B,C,D,E,F = 2,3,2,7,2,2
res = 19(approx)
Q16: Write equivalent Postfix expressions for the infix expressions given below :
(i) A+B-D/X    (ii) (X+Y)/(2*Y)-R
(i) A B + D X / -
(ii)X Y + 2 Y * / R -
Q17: Evaluate the following postfix notation of expression: 10  20+25  15-*30/
10  20+25  15-*30/
10
20
10
10+20 = 30
25
30
15
25
30
25-15 =10
30
30*10 = 300
30
300
300/30 = 10
res = 10
Q18: Evaluate the following postfix notation of expression: 20  10+5  2*-10/
20  10+5  2*-10/
20
10
20
20+10 = 30
5
30
2
5
30
5*2 = 10
30
30-10 = 20
10
20
20/10 = 2
res = 2
Q19: Evaluate the following postfix expression using a stack and show the contents of the stack after the execution of each operation :
120,45,20, +, 25,15,-,+,*
120,45,20, +, 25,15,-,+,*
45
120
20
45
120
45+20 = 65
120
25
65
120
15
25
65
120
25-15 = 10
65
120
65+10 = 75
120
120*75
res = 9000
Q20: Evaluate the following postfix expression using a stack and show the contents of stack after execution of each operation:
20,45,+,20,10,-,15,+,*
20,45,+,20,10,-,15,+,*
45
20
65
20
65
10
20
65
10
65
15
10
65
25
65
65*25
res = 1625
Q21: Use a stack to evaluate the following postfix expression and show the content of the stack after execution of each operation.  Don’t write any code.  Assume as if you are using push and pop member functions of the stack AB-CD+E*+
(where A=5,B=3,C=5,D=4,and E=2)
5 3 - 5 4 + 2 * +
3
5
2
4
5
2
9
2
2
9
2
18
2
20
res = 20
Q22: Change the following infix expression into postfix expression.(A+B)*C+D/E-F
postfix = A B + C * D E / + F -
A(+
AB(+
AB+
AB+C*
AB+C*+
AB+C*D+/
AB+C*DE+/
AB+C*DE
AB+C*DE/+
AB+C*DE/+F-
Q23: Evaluate the following postfix notation of expression :
(Show status of Stack after each operation)
True, False, NOT,OR,False,True,OR,AND
ORDER OF OPERATOR  NOT>AND>OR

True, False, NOT, OR, False, True, OR, AND
True
False
True
NOT False
True
True OR (NOT False)
False
True OR (NOT False)
True
False
True OR (NOT False)
False OR True
True OR (NOT False)
True OR (NOT False) AND False OR True
ans = True
Q24: Convert the following infix expression to its equivalent postfix expression showing stack contents for the conversion :
X-Y/(Z+U)=V
X-Y/(Z+U)=V
X
XY-/
XY-/(
XYZ-/(
XYZ-/(+
XYZU-/(+
XYZU+-/
V= XYZU+/-
Q25: Convert the following infix expression to its equivalent postfix expression showing stack contents for the conversion :
A+B*(C-D )/ E
A+B*(C-D )/ E
A
A+
AB+
AB+*
AB+*(
ABC+*(
ABC+*(-
ABCD+*(-
ABCD-*+
ABCD-*+/
ABCD-*E/+

Clear Doubts with Computer Tutor
In case you’re facing problems in understanding concepts, writing programs, solving questions, want to learn fun facts | tips | tricks or absolutely anything around computer science, feel free to join CTs learner-teacher community: students.computertutor.in

You cannot copy content of this page