Skip to content

KITSCTCLab/exercise-1---array-implementation-of-stack-adt-Yakin1001

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Problem

Perform the operations on stack.

You have an empty sequence, and you will be given queries. Each query is one of these two types.

1   x -Push the element x into the stack.
2     -Delete the element present from the top of the stack.

Function Description

Complete the functions, push, pop, is_empty, is_full, and status. They must perform the actions as described above. The function, status displays the current available elements of stack, if it is not empty.

Constraints

The size of the stack may range from 1 to 100.
The number of queries may range from 1 to 100.

Input Format

The first line contains two integers. First integer represents maximum capacity of stack and second integer represents number of queries. Each of the next q lines contains a single query in the form described in the problem statement above. All queries start with an integer denoting the query type, but only query 1 is followed by an additional space-separated value, x, denoting the value to be enqueued.

Sample Input with explaination

5   4     # size is 5 and number of queries are 4
1   10   # Push 10
2         # Perform pop
1   13   # Push 13
1   11   # Push 11

Sample Output

13
11

Sample Input-1

3   1
1   22

Sample Output-1

22

Sample Input-2

5   5
1   10
1   20
1   30
1   40
1   50

Sample Output-2

10
20
30
40
50

About

exercise-1---array-implementation-of-stack-adt-Yakin1001 created by GitHub Classroom

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages