Example #1
0
 //[Test]
 public void TestCase1()
 {
     int[] expected = { 2, 3, 5, 5, 6, 8, 9 };
     int[] input    = { 8, 5, 2, 9, 5, 6, 3 };
     //Utils.AssertTrue(compare(Program.QuickSort(input), expected));
     var result = compare(Program1.QuickSort(input), expected);
 }
Example #2
0
 //[Test]
 public void TestCase1()
 {
     var array = new int[] { 1, 2 };
     //var expected = true;
     var actual = Program1.IsMonotonic(array);
     //Utils.AssertEquals(expected, actual);
 }
Example #3
0
 //[Test]
 public void TestCase1()
 {
     int[,] input = { { 1, 2 }, { 4, 3 }, { 5, 6 }, { 6, 7 } };
     //int[,] input = { { 4,3 }, { 1, 2 }, { 5, 6 }, { 6, 7 } };
     Tuple <int, int[]> expected = Tuple.Create(10, new int[] { 1, 3 });
     //Utils.AssertTrue(compare(Program.KnapsackProblem(input, 10), expected));
     //Program1.KnapsackProblem(input, 10);
     bool result = compare(Program1.KnapsackProblem(input, 10), expected);
 }
Example #4
0
        //[Test]
        public void TestCase1()
        {
            var root = new Program1.BST(10);

            root.left           = new Program1.BST(5);
            root.left.left      = new Program1.BST(2);
            root.left.left.left = new Program1.BST(1);
            root.left.right     = new Program1.BST(5 - 2);
            root.right          = new Program1.BST(15);
            root.right.right    = new Program1.BST(22);

            //Utils.AssertFalse(Program1.ValidateBst(root));
            Program1.ValidateBst(root);
        }
Example #5
0
        //[Test]
        public void TestCase1()
        {
            TestBinaryTree tree = new TestBinaryTree(1).Insert(new List <int>()
            {
                2, 3, 4, 5, 6, 7, 8, 9, 10
            });
            List <int> expected = new List <int>()
            {
                15, 16, 18, 10, 11
            };

            Program1.BranchSums(tree);
            //Utils.AssertTrue(Program1.BranchSums(tree).SequenceEqual(expected));
        }
Example #6
0
 //[Test]
 public void TestCase1()
 {
     int[,] input =
     {
         {  1,  2,  3, 4 },
         { 12, 13, 14, 5 },
         { 11, 16, 15, 6 },
         { 10,  9,  8, 7 },
     };
     var expected = new List <int> {
         1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
     };
     var actual = Program1.SpiralTraverse(input);
     //Utils.AssertTrue(expected.SequenceEqual(actual));
 }
Example #7
0
        //[Test]
        public void TestCase1()
        {
            var array = new List <int> {
                1, 2, 5, 7, 10, 13, 14, 15, 22
            };
            var tree = Program1.MinHeightBst(array);

            //Utils.AssertTrue(validateBst(tree));
            //Utils.AssertEquals(4, getTreeHeight(tree));

            var inOrder = inOrderTraverse(tree, new List <int>
            {
            });
            var expected = new List <int> {
                1, 2, 5, 7, 10, 13, 14, 15, 22
            };
            //Utils.AssertTrue(Enumerable.SequenceEqual(inOrder, expected));
        }
Example #8
0
        //[Test]
        public void TestCase1()
        {
            List <object> test = new List <object>()
            {
                new List <object>()
                {
                    new List <object>()
                    {
                        new List <object>()
                        {
                            new List <object>()
                            {
                                5
                            },
                        },
                    },
                }
            };

            // List<object> test = new List<object>(){
            //  5,
            //  2,
            //  new List<object>(){
            //      7, -1
            //  },
            //  3,
            //  new List<object>(){
            //      6,
            //      new List<object>(){
            //          -13, 8
            //      },
            //      4,
            //  },
            // };
            //Utils.AssertTrue(Program.ProductSum(test) == 12);

            Program1.ProductSum(test);
        }
Example #9
0
 //[Test]
 public void TestCase1()
 {
     //Utils.AssertTrue(Program.IsPalindrome("abcdcba"));
     Program1.IsPalindrome("abb");
 }
Example #10
0
 //[Test]
 public void TestCase1()
 {
     //Utils.AssertTrue(Program.CaesarCypherEncryptor("xyz", 2).Equals("zab"));
     Program1.CaesarCypherEncryptor("iwufqnkqkqoolxzzlzihqfm", 25).Equals("hvtepmjpjpnnkwyykyhgpel");
 }
Example #11
0
 //[Test]
 public void TestCase1()
 {
     int[] input = { 1, 5 };
     //Utils.AssertTrue(Program.NumberOfWaysToMakeChange(6, input) == 2);
     Program1.NumberOfWaysToMakeChange(6, input);
 }
Example #12
0
 //[Test]
 public void TestCase1()
 {
     //Utils.AssertTrue(Program.BinarySearch(new int[] {0, 1, 21, 33, 45, 45, 61, 71, 72, 73}, 33) == 3);
     Program1.BinarySearch(new int[] { 0, 1, 21, 33, 45, 45, 61, 71, 72, 73 }, 21);
 }