コード例 #1
0
ファイル: FirstGreater.cs プロジェクト: mmoroney/Algorithms
        public void FirstGreaterTest()
        {
            Func <BinaryTreeNode <int>, int, int>[] functions = new Func <BinaryTreeNode <int>, int, int>[]
            {
                FirstGreater.BruteForce,
                FirstGreater.Search
            };

            for (int i = 0; i < 10; i++)
            {
                BinaryTreeNode <int> root = BinarySearchTreeUtilities.CreateRandomBinarySearchTree(10, 0, 15);
                for (int j = 0; j <= 16; j++)
                {
                    Tests.TestFunctions(root, j, functions);
                }
            }
        }
コード例 #2
0
        public void ComputeLCATest()
        {
            Func <BinaryTreeNode <int>, int, int, BinaryTreeNode <int> >[] functions = new Func <BinaryTreeNode <int>, int, int, BinaryTreeNode <int> >[]
            {
                ComputeLCA.BruteForce,
                ComputeLCA.UseBSTProperty
            };

            for (int i = 0; i < 10; i++)
            {
                int[] data = ArrayUtilities.CreateRandomPermutation(16);
                BinaryTreeNode <int> root = BinarySearchTreeUtilities.FromArray(data);

                for (int j = 0; j < 16; j++)
                {
                    for (int k = j; k < 16; k++)
                    {
                        Tests.TestFunctions(root, j, k, functions);
                    }
                }
            }
        }