$('.first').click(function() {
alert("made it to 1");
$(this).addClass("second").removeClass("first");
});
$('.second').click(function() {
alert("made it to 2");
} );
BST.prototype.insert = function(data) {
var n = new this._Node(data, null, null);
if (this.root === null) {
this.root = n;
} else {
var current = this.root;
var parent;
while (true) {
parent = current;
if (data < current.data) {
current = current.left;
if (current === null) {
parent.left = n;
break;
}
} else {
current = current.right;
if (current === null) {
parent.right = n;
break;
}
}
}
}
};
/**
* Represents a Binary Search Tree
* @constructor
*/
var BST = function() {
this.root = null;
/**
* Node represents a node in the binary search tree
* @constructor
* @param data - the value
* @param left - left side
* @param right - right side
*/
this._Node = function(data, left, right) {
this.data = data;
this.left = left;
this.right = right;
};
};