This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Stack{ | |
| constructor(length){ | |
| this.data = new Array(length); | |
| this.pointer = 0; | |
| } | |
| push(value){ | |
| if(this.pointer === this.data.length){ | |
| throw "Overflow" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Queue{ | |
| constructor(){ | |
| this.stack1 = []; | |
| this.stack2 = []; | |
| } | |
| enqueue(data){ | |
| while(this.stack1.length){ | |
| var temp = this.stack1.pop(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //children are 2n + 1, 2 | |
| //parents are floor((n-1)/2) | |
| class MaxHeap { | |
| constructor() { | |
| this.data = new Array(10); | |
| this.size = 0; | |
| } | |
| insert(value) { |
OlderNewer