반응형
큐(Queue)
먼저 들어온 Data가 먼저 처리되는 선입선출(First In First Out, FIFO), 후입후출(Last In Last Out, LILO) 자료구조
큐(Queue) Sequence
더보기

삽입 7

삽입 5

삽입 4

삭제

삽입 6

삭제
명령: 삽입(7) → 삽입(5) → 삽입(4) → 삭제( ) → 삽입(6) → 삭제( )






Code
#include <iostream>
#include <queue>
using namespace std;
int main(void){
queue<int> q;
q.push(7);
q.push(5);
q.push(4);
q.pop();
q.push(6);
q.pop();
while(!q.empty()){
cout << q.front() << " ";
q.pop();
}
return 0;
}
출력
4 6
반응형
'Algorithm' 카테고리의 다른 글
[Algorithm] 깊이 우선 탐색(DFS, Depth First Search) (0) | 2023.04.09 |
---|---|
[Algorithm] 너비 우선 탐색(BFS, Breadth First Search) (0) | 2023.04.09 |
[Algorithm] 스택(Stack) (0) | 2023.04.09 |
[Algorithm] 심화 정렬 문제 (0) | 2023.04.09 |
[Algorithm] 계수 정렬(Counting Sort) (0) | 2023.04.09 |