Ejemplo n.º 1
0
 public static FenwickTree fenwickTree(long[] A) {
   FenwickTree fw = new FenwickTree(A.length);
   for (int i = 0; i < A.length; i++) {
     fw.addValue(i + 1, A[i]);
   }
   return fw;
 }
Ejemplo n.º 2
0
 @Test
 public void testAddValue() {
   int n = 2000;
   FenwickTree fw = new FenwickTree(n);
   long[] A = randomArray(n);
   for (int i = 0; i < A.length; i++) {
     fw.addValue(i + 1, A[i]);
   }
   long[] B = fw.toArray();
   assertArrayEquals(A, B);
 }