Exemplo n.º 1
0
        static void Main(string[] args)
        {
            BinaryTreeElement elem_left = new BinaryTreeElement(
                null,
                new BinaryTreeElement(
                    null,
                    new BinaryTreeElement(
                        null,
                        new BinaryTreeElement(
                            new BinaryTreeElement(
                                null,
                                null,
                                8),
                            null,
                            22),
                        33),
                    18 ),
                1);
            BinaryTreeElement elem_right = new BinaryTreeElement( null, null, 9);
            BinaryTreeElement elem_root = new BinaryTreeElement( elem_left, elem_right, 1);

            BinaryTree tree = new BinaryTree( elem_root );

            BinaryTreeSumVisitor sum = new BinaryTreeSumVisitor();
            BinaryTreeDepthVisitor depth = new BinaryTreeDepthVisitor();

            Console.WriteLine( sum.GetSum( tree ) );
            Console.WriteLine( depth.GetDepth( tree ) );
            Console.ReadKey();
        }
Exemplo n.º 2
0
 public int GetDepth(BinaryTree tree)
 {
     return(getElementDepth(tree.Root));
 }
Exemplo n.º 3
0
 public int GetSum(BinaryTree tree)
 {
     return getSumFromElement(tree.Root);
 }
Exemplo n.º 4
0
 public int GetDepth(BinaryTree tree)
 {
     return getElementDepth(tree.Root);
 }