Horje
valid binary tree or not Code Example
valid binary tree or not
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;
        }
    }




Csharp

Related
c# string to char Code Example c# string to char Code Example
check valid binary search tree Code Example check valid binary search tree Code Example
vs code explorer font size Code Example vs code explorer font size Code Example
unity set list of strings Code Example unity set list of strings Code Example
c# sort array string by length Code Example c# sort array string by length Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8