Queue

·자료구조
class Queue { head = null; tail = null; length = 0; //head는 enqueue(value){ const newNode = new Node(value); if(this.head){ //헤드가 있을 때 this.tail.next = newNode; //tail, head 모두 같은 노드를 참조하므로 head의 next에도 newNode가 추가 this.tail = newNode; //tail은 마지막 노드를 보도록 재할당 }else{ //헤드가 없을때 this.tail = newNode; //tail,head 같은 노드를 참조 하도록 newNode할당 this.head = newNode; //tail,head 같은 노드를 참조 하도록 newNode할당 } this...
king_hd
'Queue' 태그의 글 목록