Пример #1
0
        static void Main(string[] args)
        {
            Random r = new Random();
            int n = 50;
            int[] array = new int[n];
            for (int i = 0; i < n; i++)
            {
                array[i] = r.Next(30);
                Console.Write("{0} ", array[i]);
            }
            Console.WriteLine();

            //array = new int[] { 6, 8, 0, 2, 6, 1 };

            ISolver solver = new BruteForceSolver();
            ISolver dpsolver = new DPSolver();
            ISolver efficientSolver = new EfficientSolver();

            Console.WriteLine(solver.GetLengthOfLongestIncreasingSubSequence(array));
            Console.WriteLine(dpsolver.GetLengthOfLongestIncreasingSubSequence(array));
            Console.WriteLine(efficientSolver.GetLengthOfLongestIncreasingSubSequence(array));
        }
Пример #2
0
        static void Main(string[] args)
        {
            Random r = new Random();
            int    n = 50;

            int[] array = new int[n];
            for (int i = 0; i < n; i++)
            {
                array[i] = r.Next(30);
                Console.Write("{0} ", array[i]);
            }
            Console.WriteLine();

            //array = new int[] { 6, 8, 0, 2, 6, 1 };

            ISolver solver          = new BruteForceSolver();
            ISolver dpsolver        = new DPSolver();
            ISolver efficientSolver = new EfficientSolver();

            Console.WriteLine(solver.GetLengthOfLongestIncreasingSubSequence(array));
            Console.WriteLine(dpsolver.GetLengthOfLongestIncreasingSubSequence(array));
            Console.WriteLine(efficientSolver.GetLengthOfLongestIncreasingSubSequence(array));
        }