Exemple #1
0
        public void Question_4_3_BasicCases()
        {
            // One node tree
            var tree     = TreeHelpers.CreateBinaryTree(1, null, null);
            var expected = new List <List <int> >()
            {
                ListHelpers.CreateList(1)
            };

            Validate(expected, tree);

            // Two level tree
            tree     = TreeHelpers.CreateBinaryTree(1, 2, 0);
            expected = new List <List <int> >()
            {
                ListHelpers.CreateList(1),
                ListHelpers.CreateList(2, 0)
            };

            Validate(expected, tree);

            // Two level tree
            var temp1 = TreeHelpers.CreateBinaryTree(0, 1, 2);
            var temp2 = TreeHelpers.CreateBinaryTree(4, 5, 6);
            var temp3 = TreeHelpers.CreateBinaryTree(11, temp1, temp2);
            var temp4 = TreeHelpers.CreateBinaryTree(8, temp3, null);

            expected = new List <List <int> >()
            {
                ListHelpers.CreateList(8),
                ListHelpers.CreateList(11),
                ListHelpers.CreateList(0, 4),
                ListHelpers.CreateList(1, 2, 5, 6),
            };

            Validate(expected, temp4);
        }