コード例 #1
0
        static void Main(string[] args)
        {
            Tree <int> tree = new Tree <int>(10);

            tree.Root.LeftChild             = new Node <int>(20);
            tree.Root.RightChild            = new Node <int>(15);
            tree.Root.RightChild.LeftChild  = new Node <int>(11);
            tree.Root.RightChild.RightChild = new Node <int>(16);
            tree.Root.LeftChild.LeftChild   = new Node <int>(30);
            tree.Root.LeftChild.RightChild  = new Node <int>(25);
            Console.WriteLine(String.Join(", ", tree.PreOrder(tree.Root)));
            Console.WriteLine(String.Join(", ", tree.InOrder(tree.Root)));
            Console.WriteLine(String.Join(", ", tree.PostOrder(tree.Root)));
            Console.WriteLine(String.Join(", ", tree.BreadthFirstTraversal(tree.Root)));

            BinaryTree bTree = new BinaryTree();

            bTree.Add(10);
            bTree.Add(15);
            bTree.Add(5);
            bTree.Add(200);
            bTree.Add(250);
            Console.WriteLine(String.Join(", ", bTree.InOrder(bTree.Root)));
            Console.WriteLine(bTree.Contains(15));
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: cdcummings10/DSA2
        static void Main(string[] args)
        {
            BinaryTree BTree = new BinaryTree();

            BTree.Add(15);
            BTree.Add(5);
            BTree.Add(10);
            BTree.Add(75);
            BTree.Add(20);
            BTree.Add(11);
            BTree.Add(50);
            BTree.Add(1);
            BTree.Add(6);
            BTree.Add(32);
            BTree.Add(38);
            BTree.Add(26);
            BTree.Add(7);
            BTree.Add(200);

            Console.WriteLine(BTree.Contains(7));
            InOrder(BTree);
        }