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 TreeNode { | |
| constructor(value) { | |
| this.value = value; | |
| this.children = []; | |
| } | |
| } | |
| class Tree { | |
| constructor() { | |
| this.root = null; |
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 TreeNode { | |
| constructor(value) { | |
| this.value = value; | |
| this.children = []; | |
| } | |
| } | |
| class Tree { | |
| constructor() { | |
| this.root = null; |
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 Node { | |
| constructor(value){ | |
| this.value = value; | |
| this.left = null; | |
| this.right = null; | |
| } | |
| } | |
| class BinarySearchTree { | |
| constructor(){ |
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 Node { | |
| constructor(value) { | |
| this.value = value; | |
| this.next = null; | |
| } | |
| } | |
| class Queue { | |
| constructor(){ | |
| this.first = null; |
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
| // QUEUE = First In First Out | |
| const queue = []; | |
| queue.push("Resume.docx"); | |
| console.log(queue); | |
| //[ 'Resume.docx' ] | |
| queue.push("Data_Report.csv"); | |
| console.log(queue); | |
| //["Resume.docx", "Data_Report.csv"] |
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
| // QUEUE = First In First Out | |
| const queue = []; | |
| queue.unshift("Resume.docx"); | |
| console.log(queue); | |
| //[ 'Resume.docx' ] | |
| queue.unshift("Data_Report.csv"); | |
| console.log(queue); |
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 Node { | |
| constructor(value) { | |
| this.value = value; | |
| this.next = null; | |
| } | |
| } | |
| class Stack { | |
| constructor(){ | |
| this.first = null; |
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
| //STACK = LAST IN FIRST OUT | |
| const stack = []; | |
| stack.unshift({"Willow Rosenberg": "A"}); | |
| console.log(stack); | |
| //[{ "Willow Rosenberg": "A" }] | |
| stack.unshift({"Xander Harris": "C"}); | |
| console.log(stack); | |
| //[ { 'Xander Harris': 'C' }, { 'Willow Rosenberg': 'A' } ] |
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
| //STACK = LAST IN FIRST OUT | |
| const stack = []; | |
| stack.push({"Willow Rosenberg": "A"}); | |
| console.log(stack); | |
| //[{ "Willow Rosenberg": "A" }] | |
| stack.push({"Xander Harris": "C"}); | |
| console.log(stack); | |
| //[{ "Willow Rosenberg": "A" }, { "Xander Harris": "C" }] |
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
| //Incorrect! | |
| function add(thing1: number, thing2: number): string{ | |
| return thing1 + thing2 | |
| } | |
| function add(thing1: number, thing2: number): number{ | |
| return thing1 + thing2 | |
| } | |
| function printGreeting(name: string): void{ |