Skip to content

Instantly share code, notes, and snippets.

@scriptonian
Last active August 29, 2017 19:12
Show Gist options
  • Save scriptonian/b8c01582d1dbae17311bd5a034f5779c to your computer and use it in GitHub Desktop.
Save scriptonian/b8c01582d1dbae17311bd5a034f5779c to your computer and use it in GitHub Desktop.
Binary Search Tree Class Shell
//ES5 version
function TreeNode(keyValue) {
this.keyValue = keyValue;
this.left = null;
this.right = null;
this.toString = function() {
return this.keyValue;
}
}
function BinarySearchTree() {
var rootNode = null;
}
//ES2015 & beyond version
class TreeNode {
constructor(keyValue) {
this.keyValue = keyValue;
this.left = null;
this.right = null;
}
}
class BinarySearchTree {
constructor() {
let rootNode = null;
}
toString() {
return this.keyValue;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment