Beispiel #1
0
        public void MaxDepth_TreeWithDepthOfThree_ReturnsThree()
        {
            var root = new TreeNode(1, new TreeNode(2, new TreeNode(3, null, null), null), null);

            var maximumDepth = new MaximumDepth();

            Assert.That(maximumDepth.MaxDepth(root), Is.EqualTo(3));
        }
Beispiel #2
0
        public void MaxDepth_OnlyRoot_ReturnsOne()
        {
            TreeNode root = new TreeNode(1);

            var maximumDepth = new MaximumDepth();

            Assert.That(maximumDepth.MaxDepth(root), Is.EqualTo(1));
        }
Beispiel #3
0
        public void MaxDepth_NullRoot_ReturnsZero()
        {
            TreeNode root = null;

            var maximumDepth = new MaximumDepth();

            Assert.That(maximumDepth.MaxDepth(root), Is.EqualTo(0));
        }
Beispiel #4
0
        public void MaximumDepthSuccess()
        {
            TreeNode root = new TreeNode(3);

            var node9  = root.Left = new TreeNode(9);
            var node20 = root.Right = new TreeNode(20);

            node20.Left  = new TreeNode(15);
            node20.Right = new TreeNode(7);


            var result = new MaximumDepth().MaxDepth(root);

            Assert.AreEqual(result, 3);
        }
Beispiel #5
0
        public void GetDepth()
        {
            var saka8 = new Saka();
            var saka7 = new Saka();
            var saka5 = new Saka();
            var saka6 = new Saka();
            var saka3 = new Saka(0, new List <Saka> {
                saka5, saka6, saka7, saka8
            });
            var saka2 = new Saka();
            var saka4 = new Saka();
            var saka1 = new Saka(0, new List <Saka> {
                saka3, saka2
            });

            Console.WriteLine("Max Depth = " + MaximumDepth.MaxDepth(saka1, 1000, 1));

            Console.ReadKey();
        }