Question: need help with the logic and implementation of this function for a Binary Search Tree in C++ EFFECTS : Returns a pointer to the Node
need help with the logic and implementation of this function for a Binary Search Tree in C++
EFFECTS : Returns a pointer to the Node containing the smallest element in the tree rooted at 'node' that is greater than 'item'. Returns a null pointer if the tree is empty or if it does not contain any elements that are greater than 'item'. This function must be linear recursive.
HINT: At each step, compare 'item' the the current node (using the 'less' parameter). Based on the result, you gain some information about where the element you're looking for could be. The less comparator essentially compares to values to see if the first element is smaller than the second, i.e. if int one = 1 and int two = 2, then the statement less(one, two) would be true.
static Node * min_greater_than_impl(Node *node, const T &item, Compare less) {
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
