Jun 개발노트

기본 자료구조

January 13, 2020

자바스크립트로 구현한 기본 자료구조

class Que{
    constructor(){
        this._arr = [];
    }
    enqueue(item){
        this._arr.push(item)
    }
    dequeue(){
        return this._arr.shift()
    }
}

class Stack{
    constructor(){
        this._arr = [];
    }
    push(item){
        this._arr.push();
    }
    pop(){
        this.pop();
    }
    peak(){
        return this._arr[this._arr.length-1]
    }
}

class Node{
    constructor(content, children=[]){
        this.content = content;
        this.children = children;
    }
}

Written by Junho You 배운것을 기록하자