a big-Oh characterization, in terms of n

icon
Related questions
Question

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

36 /** Returns the number of times second array stores sum of prefix sums from first. */
37 public static int example5(int[] first, int[] second) { // assume equal-length arrays
38
39
// loop from 0 to n-1
40
41
// loop from 0 to n-1
42
// loop from 0 to j
43
44
45
46
47 }
int n = first.length, count = 0;
for (int i=0; i<n; i++) {
int total = 0;
for (int j=0; j<n; j++)
for (int k=0; k<=j; k++)
total += first[k]:
if (second[i] == total) count++;
}
return count;
Transcribed Image Text:36 /** Returns the number of times second array stores sum of prefix sums from first. */ 37 public static int example5(int[] first, int[] second) { // assume equal-length arrays 38 39 // loop from 0 to n-1 40 41 // loop from 0 to n-1 42 // loop from 0 to j 43 44 45 46 47 } int n = first.length, count = 0; for (int i=0; i<n; i++) { int total = 0; for (int j=0; j<n; j++) for (int k=0; k<=j; k++) total += first[k]: if (second[i] == total) count++; } return count;
Expert Solution
Step 1: The details given in the above question is mentioned below as,

Given :-

In the above question, a method using java is mentioned 

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer