public static void PrintNode(TreeNode root) { int maxLevel = BTreePrinter.MaxLevel(root); PrintNodeInternal(new List <TreeNode>() { root }, 1, maxLevel); }
private static int MaxLevel(TreeNode node) { if (node == null) { return(0); } return(Math.Max(BTreePrinter.MaxLevel(node.Left), BTreePrinter.MaxLevel(node.Right)) + 1); }