You are on page 1of 1

eksrhyky usg: jk"Vªh; izkS|ksfxdh laLFkku bykgkckn

प्रयागराज &211004 [Hkkjr]


Motilal Nehru National Institute of Technology Allahabad
Prayagraj-211004 [India]

Department of Computer Science and Engineering


Home Assignment 2
Programme Name: B. Tech. Semester: III

Course Code: CS13101 Course Name: Data Structures

Branch: Computer Science & Engineering

Instructions:
1. This is a handwritten assignment. You need to scan the written assignment and post the solution.
You can keep the hard copy for preparation of examination.
2. Last date of submission is 09/09/2020.

Mapped to
CO number
Q1 Change the following infix expression postfix and prefix expression: 2
(A + B)*C+D/E-F

Q2 Convert the following infix expression to postfix expression. Show the contents of the 2
stack at every step.
(True && False) || !(False || True)

Q3 Use a stack to evaluate the following postfix expression and show the content of the stack 2
after execution of each operation. 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)

Q4 Evaluate the following postfix expression using a stack and show the contents of stack 2
after execution of each operation:
50,40,+,18, 14,-, *

Q5 Evaluate the following postfix expression using a stack and show the contents of stack 2
after execution of each operation:
TRUE, FALSE, TRUE, FALSE, NOT, OR, TRUE, OR, OR, AND

Q6 Suppose you want to implement two stacks in a single array. Two possibilities are outlined 2
here:
Odd-even strategy: Stack 1 uses locations 0,2,4,... of the array, whereas Stack 2 uses
the array locations 1,3,5,...
Colliding strategy: The two stacks start from the two ends of the array and grow in
opposite directions (towards one another).
Implement both the strategies. Write two sets of initialize, push and pop functions.

Page 1 of 1

You might also like