I have been avoiding this. Ever since I first encountered the binary tree in the Daily Coding Problems, I have been procrastinating on this topic. If ever my impostor syndrome regarding my abilities or designation as a 'programmer' had effect it is in situations like this. But, I can't avoid it forever, and you every journey starts with one step, so here we go!
A binary tree is a data structure that has at most, two children. Since a binary tree can only have at most 2 children, we name them left or right.
A node on a tree contains the following:
Below is the most basic definition of a node in a binary tree:
class Node {
constructor(data) {
this.data = data;
this.left = null;
this.right = null;
}
// Todo
}
To be continued...
Hat Tip to Geeks for Geeks