Compilation error (line 33, col 13): 'Program.Node' does not contain a constructor that takes 3 arguments
Compilation error (line 34, col 13): 'Program.Node' does not contain a constructor that takes 3 arguments
Compilation error (line 35, col 13): 'Program.Node' does not contain a constructor that takes 3 arguments
using System;
public class Program
{
public class Node
{
public int value;
public Node left;
public Node right;
}
public static bool IsValidBST(Node root) {
return IsValid (root, int.MinValue, int.MaxValue);
}
private static bool IsValid (Node node, int Min, int Max)
{
if (node == null)
return true;
if((node.value > Min && node.value < Max) && IsValid (node.left , Min, node.value) && IsValid(node.right, node.value, Max))
return true;
else
return false;
}
public static void Main()
{
Node n1 = new Node(1,null,null);
Node n3 = new Node(3,null,null);
Node n2 = new Node(2, n1, n3);
Console.WriteLine(IsValidBST(n2));
Console.ReadLine();
}
}