📅  最后修改于: 2022-03-11 14:48:42.094000             🧑  作者: Mango
public bool IsBinaryTree(Node node, int min = int.MinValue, int max = int.MaxValue)
{
if (root == null)
return true;
if (node.data < min || node.data > max)
return false;
return IsBinaryTree(node.leftChild,min,node.data-1) &&
IsBinaryTree(node.rightChild,node.data+1,max);
}
// node Structure
public class Node
{
public int data;
public Node leftChild;
public Node rightChild;
public Node(int data)
{
this.data = data;
}
}