728x90
이번에 볼 자료구조는 스택과 비슷한 큐 입니다.
2021.09.16 - [Programming/자료구조] - 큐 Queue
큐 Queue
이번에는 스택과 비슷한 자료구조인 큐를 알아보겠습니다. 1. 큐 큐는 스택처럼 특정한 위치에서 넣고 뺄 수 있는 자료구조입니다. 스택은 입구와 출구가 같아서 나중에 들어간 자료가 먼저 나
bamtory29.tistory.com
class Queue {
constructor() {
this.front = null;
this.rear = null;
this.size = 0;
}
enQueue(data) {
const newNode = new Node(data);
if(!this.front) {
this.front = newNode;
}
else {
this.rear.nextNode = newNode;
}
this.rear = newNode;
this.size++;
}
deQueue() {
if (!this.front) {
return false;
}
this.front = this.front.nextNode;
this.size--;
}
peak() {
return this.front.data;
}
}
https://github.com/Bam-j/algorithm-study/blob/main/study-code/data-structure/Queue.js
GitHub - Bam-j/algorithm-study: 블로그 알고리즘 정리 포스트 코드 수록 + 코딩 테스트 코드 수록
블로그 알고리즘 정리 포스트 코드 수록 + 코딩 테스트 코드 수록. Contribute to Bam-j/algorithm-study development by creating an account on GitHub.
github.com
728x90
'Programming > 자료구조' 카테고리의 다른 글
[Javascript] 그래프 (0) | 2021.11.22 |
---|---|
[Javascript] 이진 탐색 트리 (0) | 2021.11.18 |
[Javascript] 스택 (0) | 2021.11.17 |
[Javascript] 연결 리스트 (0) | 2021.11.17 |
그래프 탐색 - 너비 우선 탐색 BFS (0) | 2021.10.09 |
댓글