You are viewing a single comment's thread. Return to all comments →
jongray93's solution returns false on your tree. In the first iteration, on the root node, the code will check the last condition:
return check(n.left, min, n.data)
&& check(n.right, n.data, max);
The right node will return true because n.right is NULL, and the left will continue searching down the three, with the max value updated to 2 (root's data value). Therefore any node whose data is greater than 2 (your last node) will return false.