Exemplo n.º 1
0
        public void RandomAggreagateTreapTest()
        {
            IAggregateTreap <int> fstTreap = new AggregateTreap <int>(AddMonoid.Instance);
            IAggregateTreap <int> sndTreap = new TrivialImplementAggregateTreap(AddMonoid.Instance);

            GenerateTreap(fstTreap, 42);
            GenerateTreap(sndTreap, 42);

            Assert.That(EqAggregateTreap(fstTreap, sndTreap));
        }
Exemplo n.º 2
0
        public void ArithmeticSumAggregateTreapTest()
        {
            AggregateTreap <int> treap = new AggregateTreap <int>(AddMonoid.Instance);

            for (int i = 0; i < 1000; i++)
            {
                treap.Insert(i, i + 1);
            }

            bool bo = true;

            for (int i = 0; i < treap.Count; i++)
            {
                for (int j = i; j < treap.Count; j++)
                {
                    bo &= treap.Aggregate(i, j) == (i + j + 2) * (j - i + 1) / 2;
                }
            }

            Assert.That(bo);
        }