본문 바로가기
알고리즘/이론

[알고리즘 이론] 큐(Queue)

by 응애~ 개발자 2025. 3. 21.
728x90
반응형

이론

 이본에 볼 자료구조는 큐이다. 스택은 FIFO 입선출인 자료구조이다. 즉 먼저들어간게 먼저 들어 온다는 뜻이다.

 큐에 자세한 내용은 아래의 사이트에서 확인해라.

https://namu.wiki/w/%ED%81%90(%EC%9E%90%EB%A3%8C%EA%B5%AC%EC%A1%B0)

 

큐(자료구조)

파일:attachment/큐(자료구조)/queue.png 선입선출(先入先出/First In First Out—FIF

namu.wiki

 

 

Javascript

class Queue{
    constructor(){
        this.items = [];
        this.start = 0;
        this.size = 0;
    }


    push(val){
        this.items.push(val);
        this.size++;
    }

    pop(){
        this.size--;
        return this.items[this.start++]
    }

    isEmpty(){
        return this.size === 0;
    }

}

 

728x90
반응형