Exemple #1
0
        public void SumTest()
        {
            BinaryIndexedTree bit = new BinaryIndexedTree(10);

            bit.Add(0, 1);
            bit.Add(1, 2);
            bit.Add(2, 3);
            bit.Add(3, 4);
            bit.Add(4, 5);

            Assert.AreEqual(15, bit.Sum(4));
        }
Exemple #2
0
        public void InitTest()
        {
            BinaryIndexedTree bit = new BinaryIndexedTree(10);

            bit.Init(2);
            bit.Add(0, 1);
            bit.Add(1, 2);
            bit.Add(2, 3);
            bit.Add(3, 4);
            bit.Add(4, 5);

            Assert.AreEqual(22, bit.Sum(1, 4));
            Assert.AreEqual(25, bit.Sum(0, 4));
        }