void Tree::add (int val) { binaryTreeNode *tmp; bool done = false; if (NULL == root) { root = new binaryTreeNode (val); } else { tmp = root; while (!done) { if (val < tmp->getValue ()) { if (NULL == tmp->getLeftChild ()) { tmp->setLeftChild (new binaryTreeNode (val)); done = true; } else { tmp = tmp->getLeftChild (); } } else // the new value >= value at tmp { if (NULL == tmp->getRightChild ()) { tmp->setRightChild (new binaryTreeNode (val)); done = true; } else { tmp = tmp->getRightChild (); } } } } }