rendered paste body.... from BSTree.h ........
class BSTree{
public:
BSTree();
~BSTree();
void insert(double); //Wrapper for insert(BSTreNode*)
double min(); //Wrapper for min(BSTreeNode*);
private:
void insert(BSTreeNode*);
BSTreeNode* min(BSTreeNode*);
BSTreeNode* root;
};
...................................................
....from BSTree.cpp ......
BSTree::BSTree() { root = 0; }
void BSTree::insert(BSTreeNode* n){
BSTreeNode* t = root; //Tree cursor
BSTreeNode* p = 0; //Keep track of parent node
std::cout<<n->getKey()<<" "<<root->getKey(); ////THIS IS WHERE I GET SOME INSANELY LARGE DOUBLE FOR root's getkey.
while(t!=0){ //As long as t points to a node.
p = t;
if(n->getKey() < p->getKey())//Traverse Left Branch
{t = t->getLeft();}
else{t = t->getRight(); } //Traverse Right Branch
}
std::cout<<"wassabi!";
n->setParent(p); //Set n's parent
if(p == 0){
root = n;
return;
}
if(n->getKey() < p->getKey()) //Set p's child appropriately
p->setLeft(n);
else{ p->setRight(n); }
}