Binary Search Tree
BinarySearchTree.prototype.contains = function(v) {
return this.traverse().includes(v); // or indexOf
}
//...
BinarySearchTree.prototype.traverse = function(direction) {
// get values array
if (!directon) {
return array.reverse();
}
}
function BinarySearchTree() {
this._root = null;
}
BinarySearchTree.prototype = function() {
if (this._root) {
return this._root;
}
}
//or...
function BinarySearchTree() {
this._root = new Node();
}
function Node(key, value) { ... }
Node.prototype.append = function() { ... }
Node.prototype.swap = function() { ... }
Node.prototype.MAGIC = function() { ... }
BinarySearchTree.prototype.search = function(k) {
//logic here...
if (!value) {
return 'undefined';
}
}
var mySuperValue = bst.search(42);
var check = !!mySuperValue; // true
throw 'Not found!!1';
//...
throw Error('Not found');
function ( var) {
this.append =null;
if(flag) throw 'AAAAAA!!1';
return undefined;
}