コード例 #1
0
        public void TestAdd_ShouldAddElements()
        {
            _binaryTree.Add(4);
            _binaryTree.Add(30);

            var result = new int[] { _binaryTree.Root.LeftChild.RightChild.RightChild.LeftChild.Data, _binaryTree.Root.RightChild.RightChild.RightChild.Data };

            result.Should().BeEquivalentTo(new int[] { 4, 30 });
        }
コード例 #2
0
        static void BinaryTreeMain()
        {
            var tree = new DataStructures.BinaryTree.BinaryTree <int>(15);

            tree.Add(1);
            tree.Add(3);
            tree.Add(20);
            tree.Add(14);
            tree.Add(28);
            tree.Add(2);
            tree.Add(25);
            tree.Add(16);
            tree.Remove(3);
            tree.Remove(666);

            BinaryTree <int> .BFS(tree.Root, Console.WriteLine);

            DFS(tree.Root);
        }