Returns the sum of the prefix sums of given array. / public static int example4(int[] arr) { int n-arr.length, prefix=0, total - 0: for (int i=0; j

icon
Related questions
Question

 Give a big-Oh characterization, in terms of n, of the running time 

26 / Returns the sum of the prefix sums of given array. */
27 public static int example4(int[] arr) {
28
29
int narr.length, prefix = 0, total = 0;
for (int i=0; j<n; j++){
prefix += arr[i]:
total += prefix;
30
31
32
33
34
35
}
return total;
}
// loop from 0 to n-1
Transcribed Image Text:26 / Returns the sum of the prefix sums of given array. */ 27 public static int example4(int[] arr) { 28 29 int narr.length, prefix = 0, total = 0; for (int i=0; j<n; j++){ prefix += arr[i]: total += prefix; 30 31 32 33 34 35 } return total; } // loop from 0 to n-1
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer