Exemplo n.º 1
0
        private void Test(MCO mco, int[] matrix)
        {
            int min          = mco.MatrixChainOrder(matrix);
            int minWithRecur = mco.MatrixChainOrderWithRecur(matrix);

            Console.WriteLine($"The min matrix product of {string.Join(",", matrix)} is {min} and {minWithRecur}(Recur)");
        }
Exemplo n.º 2
0
        public void Test()
        {
            MCO mco = new MCO();

            int[] matrix;
            matrix = new int[] { 10, 30, 5, 60 };
            Test(mco, matrix);
            matrix = new int[] { 4, 2, 3, 1, 3, 5, 6 };
            Test(mco, matrix);
            //expect answer is 93
            matrix = new int[] { 1, 3, 9, 7, 1 };
            Test(mco, matrix);
            for (int i = 0; i < 5; i++)
            {
                Random random = new Random(i);
                matrix = GetNumbers(random, 5);
                Test(mco, matrix);
                // Thread.Sleep(100);
            }
        }