コード例 #1
0
        /* Driver code */
        public static void Main(String[] args)
        {
            BinaryTree tree = new BinaryTree();

            tree.root                   = new Node1(10);
            tree.root.left              = new Node1(2);
            tree.root.right             = new Node1(10);
            tree.root.left.left         = new Node1(20);
            tree.root.left.right        = new Node1(1);
            tree.root.right.right       = new Node1(-25);
            tree.root.right.right.left  = new Node1(3);
            tree.root.right.right.right = new Node1(4);
            Console.WriteLine("maximum path sum is : " +
                              tree.findMaxSum());
            Console.WriteLine("Height of tree is : " +
                              tree.maxDepth(tree.root));
            //Output
            //Height of tree is 2
            //https://www.geeksforgeeks.org/tree-traversals-inorder-preorder-and-postorder/
            //http://cslibrary.stanford.edu/110/BinaryTrees.html
            //try all below for AMZ binary tree
            //https://www.geeksforgeeks.org/amazon-interview-experience-for-sde-off-campus/
        }