Question: DLList common _ ancestors ( const T & val 1 , const T & val 2 ) const { if ( ! contains ( val
DLList commonancestorsconst T & val const T & val const
if containsvalcontainsval
return DLList;
DLList ancestors;
if val val
BSTNode node root;
while node
ancestors.addtotailnodeval;
if val nodeval
node nodeleft;
else if val nodeval
node noderight;
else
break;
else
findCommonAncestorsroot val val ancestors;
return ancestors;
ADD YOUR IMPLEMENTATION HERE
bool BST::findCommonAncestorsBSTNode node, const T& val const T& val DLList& ancestors const
if node
return false;
bool foundInLeft findCommonAncestorsnodeleft, val val ancestors;
bool foundInRight findCommonAncestorsnoderight, val val ancestors;
if foundInLeft && foundInRightnodeval val nodeval val
ancestors.addtotailnodeval;
return true;
return foundInLeft foundInRight nodeval val nodeval val;
where is the error in the above code when i get this error Oops something is wrong with your solution:
Nodes were inserted into the BST in this order:
Your result from commonancestors:
Correct result from commonancestors:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
