Beispiel #1
0
        public static void PrintNode(TreeNode root)
        {
            int maxLevel = BTreePrinter.MaxLevel(root);

            PrintNodeInternal(new List <TreeNode>()
            {
                root
            }, 1, maxLevel);
        }
Beispiel #2
0
        private static int MaxLevel(TreeNode node)
        {
            if (node == null)
            {
                return(0);
            }

            return(Math.Max(BTreePrinter.MaxLevel(node.Left), BTreePrinter.MaxLevel(node.Right)) + 1);
        }