Assignment 2
Assignment 2
NOTE:
1. You are required to take print out of this sheet and solve (handwritten) the questions on sheet
only. [Submissions not conforming to the given format will not be evaluated]
2. Copying of solution is strictly prohibited. In case it is found, then zero marks will be awarded.
3. Submit the scan copy of your solution on eclass. Late submissions are not accepted.
4. You are required to keep a hard copy of the assignment with you. This may be requested at a later
date for verification purposes.
Questions
1 . Consider the following stack, where STACK is allocated N=6 memory cells
1. PUSH(KKK)
2. POP()
3. PUSH(LLL)
4. PUSH(SSS)
5. POP()
6. PUSH(TTT)
Solution:
ID: Name:
(a) A B + C * D –
Solution:
(b) ABC * + D –
Solution:
ID: Name:
(a) * – + A B C D
Solution:
(b) + – A * B C D
Solution:
ID: Name:
4. Write a function that accepts two stacks. Copy the contents of first stack in the second stack.
Note that the order of elements must be preserved.
Solution: