● videoReview
Review: Data Structures

Unlock this course
Subscribe for full access to every course, or buy this one on its own.
SECTION
Review
NEXT UP
Review: Algorithms and Strategies
COURSE
Coding Interview Bootcamp
17 lessons
About this lesson
The Code
To get you off the ground, feel free to use the code bits below. The first is for a basic tree Node:
class Node{
constructor(val){
this.value = val;
this.children = [];
}
addChild(val){
const newNode = new (val);
this.children.push(newNode);
return newNode;
}
}
module.exports = Node;
Here’s one for a BinaryTreeNode
class BinaryTreeNode{
constructor(val){
this.value = val;
this.right = null;
this.left = null;
}
addRight(val){
const newNode = new BinaryTreeNode(val);
this.right = newNode;
return newNode;
}
addLeft(val){
const newNode = new BinaryTreeNode(val);
this.left = newNode;
return newNode;
}
}
Unlock Coding Interview Bootcamp
Subscribe for full access to every course, or buy this one on its own.