Example #1
0
BinaryNode<T> *BST<T>::find_max(BinaryNode<T> *node) {

	// 	Keep going down rhs until rhs == NULL. Then return the node
	BinaryNode<T> *tmp = node;

	while (tmp->get_rhs() != NULL){
		tmp = tmp->get_rhs();
	}

	return tmp;



	// 	THIS IS ALL COMMENTED OUT TEMPORARILY BECAUSE OF ISSUES WITH ACCESSING THE NODES IN TREE
	// 	if (root != NULL){
	// 		BinaryNode<T> * entire_fucking_tree;
	// 		entire_fucking_tree = root;
	// 		root = NULL;
	// 		return entire_fucking_tree;
	// 	}
	// 		

	// TODO: Implement this function
	throw 1;
	// TODO: Implement this function (when you have a use for it)
	return NULL;
}
Example #2
0
BST<T>::~BST() {
	Queue<BinaryNode<T>* > jerry;
	if (root == NULL)
		get_the_fuck_outta_here;
	jerry.enqueue(root);
	while (!jerry.is_empty()){
		BinaryNode<T>* tmp = jerry.dequeue();

		if (tmp->get_lhs() != NULL)
			jerry.enqueue(tmp->get_lhs());
		if (tmp->get_rhs() != NULL)
			jerry.enqueue(tmp->get_rhs());
		delete tmp;
	}




	// TODO: Write this function
	// TODO: Copy your lab7 implementation here
}