Question 4 [5] with sample solutions

For the bstree class specified in the attached definitions page (at the back of the exam), provide implementations of the public lookup and update methods.

For this question you may assume all the private bstree methods have already been correctly implemented, so you may call any of them as needed.
SAMPLE SOLUTION
bool bstree::update(int idVal, float dataVal)
{
   node *n = find(idVal, root);
   if (n == NULL) return false;
   n->data = dataVal;
   return true;
}

bool bstree::lookup(int idVal, float &dataVal)
{
   node *n = find(idVal, root);
   if (n == NULL) return false;
   dataVal = n->data;
   return true;
}