Algorithm · Akuna Capital · Easy
Given the following C++ binary-tree node definition: Implement a recursive depth-first function int maxValue(TreeNode* root) that returns the greatest integer stored in the tree. The required base-case contract is: a call with root == nullptr must return INT_MIN. This sentinel keeps an absent left or right child from replacing a valid stored value. For a non-null root, return the maximum value found across all nodes. If the public caller invokes this function on an empty…
Checking your access…