Last active
September 5, 2017 15:41
-
-
Save scriptonian/e1f1b7ab05aebf5fe9e35b05950a693b to your computer and use it in GitHub Desktop.
Adding the BST methods to class. Insert, find, remove, max, min and traversal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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; | |
} | |
BinarySearchTree.prototype = { | |
insert: function(key) {}, | |
find: function(key) {}, | |
remove: function(key) {}, | |
max: function(){}, | |
min: function() {}, | |
traverse: function(){} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//ES2015 & beyond | |
class TreeNode { | |
constructor(keyValue) { | |
this.keyValue = keyValue; | |
this.left = null; | |
this.right = null; | |
} | |
} | |
class BinarySearchTree { | |
constructor() { | |
let root = null; | |
} | |
toString() { | |
return this.keyValue; | |
} | |
insert(key) {} | |
find(key) {} | |
remove(key) {} | |
max(){} | |
min() {} | |
traverse(){} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment