public int mindepth = int.MaxValue;
public void finddepth(Tree node, int height)
if (node.left == null && node.right == null)
finddepth(node.left, height + 1);
finddepth(node.right, height + 1);
public static void Main()
Program p = new Program();
p.head.left = new Tree(2);
p.head.right = new Tree(3);
p.head.left.left = new Tree(4);
p.head.left.right = new Tree(5);
p.head.right.right = new Tree(6);
Console.WriteLine(p.mindepth);