Exemple #1
0
        private static int MaxLevel(Node node)
        {
            if (node == null)
            {
                return(0);
            }

            return(Math.Max(BinaryTreePrinter.MaxLevel(node.LeftChild), BinaryTreePrinter.MaxLevel(node.RightChild)) + 1);
        }
Exemple #2
0
        public static void PrintNode(Node root)
        {
            int maxLevel = BinaryTreePrinter.MaxLevel(root);

            PrintNodeInternal(new List <Node>()
            {
                root
            }, 1, maxLevel);
        }