Example #1
0
 public void TestMethod1()
 {
     int[] array = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 };
     SegmentTree tree = new SegmentTree(array);
     tree.PlusSegment(0, 7, 5);
     int sum = tree.Sum(0, 7);
     Assert.AreEqual(40, sum);
 }
Example #2
0
        public void Test()
        {
            int[] array = new int[] { 7, 8, 3, 4, 2, };
            SegmentTree tree = new SegmentTree(array);
            tree.PlusSegment(0, 4, 1);
            tree.AssignSegment(0, 4, 0);
            tree.Assign(1, 3);
            tree.Plus(2, -1);

            Assert.AreEqual(2, tree.Sum(0, 4));
        }