JSFiddle - React, Tailwind, and code Playground

by kkdaily

HTML

<h3>
Tree DS
</h3>

JavaScript

class Node {
	constructor(value) {
		this.value = value
    this.leftChild = null
    this.rightChild = null
  }
}

class BinaryTree {
	constructor() {
  	this.root = null
  }
  
  insertLeft(node, value) {
  	if (node.leftChild) {
    	const newNode = new Node(value)
      newNode.leftChild = node.leftChild
    }
  }
  
  insertRight(node, value) {
  	if (node.rightChild) {
    	const newNode = new Node(value)
      newNode.rightChild = node.rightChild
    }
  }
}