StackBasicOperations-CSE E


Submit solution

Points: 30
Time limit: 1000.0s
Memory limit: 64M

Author:
Problem type
Allowed languages
C++, Python

This is a simple data structures problem. Your goal is to complete the stack ADT and evaluate its functions.

Input:
  • First line will contain T, number of testcases. Then the testcases follow.
  • Each testcase contains integers N, M, where N is the size of the stack, and M is the number of operations in the test case. Next line will include the size, and next M lines will include series of operations of the following type Character, value, where character indicates the stack operation P-push, O-pop, T-top, S-size, I-isempty.
Output:

For each testcase, output the result of each operation separated by a newline.

  • The output of Push should be the content of the stack (print function given)
  • Pop should output the popped value
  • top the value on top
  • size the size of the stack
  • isEmpty should return True or False.

If stack full when Push, output StackFullException case sensitive.

If stack empty when pop or top, output StackEmptyException case sensitive.

Constraints
  • 1 <= T <= 10

  • 10 <= N <= 100

Sample Input:
    1
    5
    11
    T
    S
    I
    P 4
    P 2
    T
    P 3
    P 5
    S
    P 9
    P 10
Sample Output:
 StackEmptyException
 None
    0
    True
    4
    4 2
    2
    4 2 3
    4 2 3 5
    4
    4 2 3 5 9
    StackFullException
    4 2 3 5 9
EXPLANATION:

Comments

There are no comments at the moment.