<commit_before>// Program that creates a binary search tree: each node has up to two children, and all left descendants of a node is less than or equal to the node and all right descendants are greater than the node

// create node class
function Node(val) {
	this.value = val;
	this.left = null;
	this.right = null;
}

// create constructor for binary search tree
function BinarySearchTree() {
	this.root = null;
}

BinarySearchTree.prototype.push = function(val){
	var rootNode = this.root;

	if(!rootNode){
		this.root = new Node(val);
		return;
	}

	var currentNode = rootNode;
	var newNode = new Node(val);

	while(currentNode){
		if(val < currentNode.value){
			if(!currentNode.left){
				currentNode.left = newNode;
				break;
			} else {
				currentNode = currentNode.left;
			}
		} else {
			if(!currentNode.right) {
				currentNode.right = newNode;
				break;
			} else {
				currentNode = currentNode.right;
			}
		}
	}
}<commit_msg>Add test case for binary search tree program<commit_after>// Program that creates a binary search tree: each node has up to two children, and all left descendants of a node is less than or equal to the node and all right descendants are greater than the node

// create node class
function Node(val) {
	this.value = val;
	this.left = null;
	this.right = null;
}

// create constructor for binary search tree
function BinarySearchTree() {
	this.root = null;
}

// function for inserting value into appropriate location in tree
BinarySearchTree.prototype.push = function(val){
	var rootNode = this.root;

	// if there is no root node
	if(!rootNode){
		this.root = new Node(val);
		return;
	}

	var currentNode = rootNode;
	var newNode = new Node(val);

	while(currentNode){
		if(val < currentNode.value){
			if(!currentNode.left){
				currentNode.left = newNode;
				break;
			} else {
				currentNode = currentNode.left;
			}
		} else {
			if(!currentNode.right) {
				currentNode.right = newNode;
				break;
			} else {
				currentNode = currentNode.right;
			}
		}
	}
}

// test case
var testTree = new BinarySearchTree();
testTree.push(4);
testTree.push(9);
testTree.push(2);
testTree.push(7);
testTree.push(3);
// expect 4 to be root node, 2 to be left child and 9 to be right child of 4, 7 to be left child of 9, and 3 to be right child of 2
console.log(testTree);







{'fraction_non_alphanumeric': 0.1030616645105649, 'fraction_numerical': 0.00560586459680897, 'mean_word_length': 3.3691148775894537, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4586354', 'n_tokens_mistral': 823, 'n_tokens_neox': 723, 'n_words': 258}