-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
Exercise_1.cpp
54 lines (44 loc) · 954 Bytes
/
Exercise_1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <bits/stdc++.h>
using namespace std;
#define MAX 1000
class Stack {
//Please read sample.java file before starting.
//Kindly include Time and Space complexity at top of each file
int top;
public:
int a[MAX]; // Maximum size of Stack
Stack() { //Constructor here }
bool push(int x);
int pop();
int peek();
bool isEmpty();
};
bool Stack::push(int x)
{
//Your code here
//Check Stack overflow as well
}
int Stack::pop()
{
//Your code here
//Check Stack Underflow as well
}
int Stack::peek()
{
//Your code here
//Check empty condition too
}
bool Stack::isEmpty()
{
//Your code here
}
// Driver program to test above functions
int main()
{
class Stack s;
s.push(10);
s.push(20);
s.push(30);
cout << s.pop() << " Popped from stack\n";
return 0;
}