예제 #1
0
파일: Program.cs 프로젝트: voter101/ooad_ii
        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();
        }
예제 #2
0
 public int GetDepth(BinaryTree tree)
 {
     return(getElementDepth(tree.Root));
 }
예제 #3
0
 public int GetSum(BinaryTree tree)
 {
     return getSumFromElement(tree.Root);
 }
예제 #4
0
 public int GetDepth(BinaryTree tree)
 {
     return getElementDepth(tree.Root);
 }