Finish Code Bool Isinbt Const Bt Bt Const Void Element Bool Eq Const Void Lhs Const Void R Q37054420

How do I finish this code?

bool IsInBT(const BT *bt,const void *element,

            bool(*EQ)(const void *LHS,const void *RHS))

//————————————————————–

{

   bool isIn = false;

   

   IsInBT2(bt->root,element,&isIn,EQ);

   return( isIn );

}

//————————————————————–

void IsInBT2(const BTNODE *node,const void *element,bool*isIn,

             bool(*EQ)(const void *LHS,const void *RHS))

//————————————————————–

{

   Student provides missing code. HintThe IOparameter isIn is initialized

      to false by IsInBT() inanticipation of the traversal of the

      binary tree *bt by IsInBT2()that visits every node in the binary

      tree and computes

      *isIn = *isIn ||EQ(element,node->element);

      NoteThis is an $xistentialquantification that answers the

     question, “Does there exist a nodein the binary tree whose

      element, node->element,is equal-to the formal parameter element?”

}


Answer


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.