17 /** Returns the sum of the prefix sums of given array. */ 18 public static int example3(int[] arr) { int n = arr.length, total = 0; for (int j=0; j

icon
Related questions
Question

giving  a big-Oh characterization , in terms of n, of the running time of following methods 

17 /** Returns the sum of the prefix sums of given array. */
18 public static int example3(int[] arr) {
19
27222
20
21
23
24
}
int n = arr.length, total = 0;
for (int i=0; j<n; j++)
for (int k=0; k <= j; k++)
total += arr[j];
return total;
// loop from 0 to n-1
// loop from 0 to j
Transcribed Image Text:17 /** Returns the sum of the prefix sums of given array. */ 18 public static int example3(int[] arr) { 19 27222 20 21 23 24 } int n = arr.length, total = 0; for (int i=0; j<n; j++) for (int k=0; k <= j; k++) total += arr[j]; return total; // loop from 0 to n-1 // loop from 0 to j
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer