-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path30.cpp
More file actions
53 lines (38 loc) · 934 Bytes
/
Copy path30.cpp
File metadata and controls
53 lines (38 loc) · 934 Bytes
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
#include <bits/stdc++.h>
using namespace std;
/*
stack - balanced paranthesis (({}))[()]
- Next Greater Element NGE
queue - bfs (breadth first search)
- its use comes mainly in graphs
Operations in stack (LIFO) :-
1. push - pushes element to top
2. pop - remove element to top
3. top - shows element at top
Operations in queue (FIFO) :-
1. push - pushes element at end
2. pop - remove element at front
3. front - shows element at front
*/
int main() {
// stack<int> s;
// s.push(2);
// s.push(3);
// s.push(5);
// s.push(9);
// while (!s.empty())
// {
// cout<<s.top()<<endl;
// s.pop();
// }
queue<string> q;
q.push("abc");
q.push("bcd");
q.push("cde");
q.push("def");
while(!q.empty()){
cout<<q.front()<<"\n";
q.pop();
}
return 0;
}