예제 #1
0
        public void TestRightAndLeftNode_ChooseLeft()
        {
            var root = new TreeNode(6, new TreeNode(9), new TreeNode(1));

            Console.WriteLine(root.Print());
            FindBottomLeftTreeValue.Find(root).Should().Be(9);
        }
예제 #2
0
        public void TestLevel4Leaf()
        {
            var root = new TreeNode();

            root.left  = new TreeNode(111, new TreeNode(666), new TreeNode(222));
            root.right = new TreeNode(333, new TreeNode(444), new TreeNode(555, new TreeNode(7)));
            FindBottomLeftTreeValue.Find(root).Should().Be(7);
        }
예제 #3
0
        public void TestTwoLevel4Leaves_DifferentBranches()
        {
            var root = new TreeNode();

            root.left  = new TreeNode(111, new TreeNode(666), new TreeNode(222, right: new TreeNode(7)));
            root.right = new TreeNode(333, new TreeNode(444), new TreeNode(555, new TreeNode(999)));
            Console.WriteLine(root.Print());
            FindBottomLeftTreeValue.Find(root).Should().Be(7);
        }
예제 #4
0
        public void TestAllLevel3Leaves_ChooseLeftLeft()
        {
            var root = new TreeNode();

            root.left  = new TreeNode(111, new TreeNode(7), new TreeNode(222));
            root.right = new TreeNode(333, new TreeNode(444), new TreeNode(555));
            Console.WriteLine(root.Print());
            FindBottomLeftTreeValue.Find(root).Should().Be(7);
        }
예제 #5
0
        public void TestSingleRightLeftLeaf()
        {
            var root = new TreeNode(0, right: new TreeNode(9, new TreeNode(7)));

            FindBottomLeftTreeValue.Find(root).Should().Be(7);
        }
예제 #6
0
        public void TestSingleLeftNode()
        {
            var root = new TreeNode(6, new TreeNode(9));

            FindBottomLeftTreeValue.Find(root).Should().Be(9);
        }
예제 #7
0
        public void TestTwoLeftLeaves_ChooseLeftLeft()
        {
            var root = new TreeNode(0, new TreeNode(9, new TreeNode(7), new TreeNode(666)));

            FindBottomLeftTreeValue.Find(root).Should().Be(7);
        }