👋🏼

Hi there!

You need to be logged in to view this course.

Jon Skeet: Binary Tree Troubles

This question is seemingly simple:

Decide if a tree is a binary tree

and then…

Decide if the tree is balanced

Another super common question you will likely be asked in one form or another. Interviewers just LOVE questions about binary tree traversal!

This question should take 30 minutes.

Some code to get you started:

//you can use an Array as a Stack or a Queue in ES6 as well
class TreeNode{
  constructor(val){
    this.value = val;

  }
  addRight(val){
    this.right = new TreeNode(val);
    return this.right;
  }
  addLeft(val){
    this.left = new TreeNode(val);
    return this.left;
  }
}