- R 4 9 Give A Big Oh Characterization In Terms Of N Of The Running Time Of The Example1 Method Shown In Code Fragment 4 1 (126.73 KiB) Viewed 23 times
R-4.9 Give a big-Oh characterization, in terms of n, of the running time of the example1 method shown in Code Fragment 4
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
R-4.9 Give a big-Oh characterization, in terms of n, of the running time of the example1 method shown in Code Fragment 4
R-4.9 Give a big-Oh characterization, in terms of n, of the running time of the example1 method shown in Code Fragment 4.12 1/** Returns the sum of the integers in given array. */ 2 public static int example1(int[] arr) { 3 int n = arr.length, total = 0; 4 for (int i=0; j<n; j++) // loop from 0 to n-1 5 total += arr[j]: 6 return total; 7 8 O(n) ○ 0(n²) O (log n) 0 (en) }