Validate Binary search tree's correctness. // Call with min = Int32.MinValue, max = Int32.MaxValue bool isValidBinSearchTree(Node<int> n, int min, int max) { if (n == null) return true; if (n.val >= min && n.val <= max && isValidBinSearchTree(n.left, min, n.val) && isValidBinSearchTree(n.right, n.val, max)) return true; return false; } |
Trees and Graphs >