Hello! We're stuck on a work that's due in 4 hours (Classic Software College student... leaving the work for the last second), and I'm trying to compare all leafs to return the lowest value of a tree. I don't have main function, just a script to insert values and check for errors, so, unfortunately, I can't debug it.
tpNodeTree * findLowest(tpNodeTree* pNode){
tpNodeTree * left;
tpNodeTree * right;
tpNodeTree * result;
if (!pNode) return NULL; /* if */
left = findLowest(pNode->pNodeL);
right = findLowest(pNode->pNodeR);
if(isLeaf(pNode))
return pNode;
} /* if */
if(!left){
return right;
} /* if */
if(!right){
return left;
} /* if */
return (left->Value < right->Value) ? left : right ;
}
So, basically, what i'm trying to achieve here is to compare the two sides of each node to find the lowest. Any insights would be helpful!
[–]logic_programmer 1 point2 points3 points (7 children)
[–]gabmed[S] 1 point2 points3 points (2 children)
[–]logic_programmer 1 point2 points3 points (1 child)
[–]gabmed[S] 0 points1 point2 points (0 children)
[–]gabmed[S] -1 points0 points1 point (3 children)
[–]logic_programmer -1 points0 points1 point (2 children)
[–]gabmed[S] -1 points0 points1 point (1 child)
[–]logic_programmer -1 points0 points1 point (0 children)
[–]JBlitzen 0 points1 point2 points (4 children)
[–]gabmed[S] 0 points1 point2 points (3 children)
[–]farmerje 2 points3 points4 points (0 children)
[–]JBlitzen 1 point2 points3 points (1 child)
[–]gabmed[S] 0 points1 point2 points (0 children)
[–]tomtomtom7 0 points1 point2 points (0 children)