Given a value in a binary search tree, write an algorithm that returns the next greatest value. The tree is assumed to contain the given value.
Sigiloso
If n has a right child: return the smallest element in the subtree where n's right child is the root else: current_node = n parent_node = n->parent while parent_node parent current_node = current_node->parent return parent_node I'm assuming you know how to find the smallest element in a subtree/tree