Data Structures

Stacks

Implementation of Stack in Javascript using ES6

Creating a Stack

Step 1: Create a stack class

class Stack {

};

Step 2: Define a data structure that will store the elements of the stack

class Stack {
    constructor () {
        this.item = [];
    }
};

Step 3: Declare methods

class Stack {

    constructor () {
        this.item = [];
    }
    insert(element) {
        this.item.push(element);
    }
    remove() {
        return this.item.pop();
    }
    peek() {
        return this.item[this.item.length - 1];
    }

    isEmpty() {
        return (this.item.length === 0);
    }

    size() {
        return this.item.length;
    }

    clear () {
        this.item = [];
    }

    print() {
        console.log(this.item.toString());
    }

    toString() {
        return this.item.toString()
    }

}

Linked Lists

Binary Search Tree

Hash Table

Algorithms

Merge Sort

Pseudo Code

Analysis: Running Time

HIGHLIGHTS BY 0