R-4.11 Give a big-Oh characterization, in terms of n, of the running time of the example3 method shown in Code Fragment
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
R-4.11 Give a big-Oh characterization, in terms of n, of the running time of the example3 method shown in Code Fragment
R-4.11 Give a big-Oh characterization, in terms of n, of the running time of the example3 method shown in Code Fragment 4.12 16 17/ Returns the sum of the prefix sums of given array. */ 18 public static int example3(int[] arr) { 19 int n arr.length, total = 0; 20 for (int i=0; j<n; j++) 21 // loop from 0 to j for (int k=0; k<=j; k++) total += arr[j]; 22 23 return total; 24 25 ○ 0(n²) ○ 0(n³) 0 (en) O (n logn) }
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!