What is the time complexity of the following algorithm? (expressed in terms of n)
Choose one of the important growth functions we covered in class: O(1), O(logn), O(n), O(nlogn), O(n2), O(n3), O(2n).
public static int example2(int[ ] arr) {
int n = arr.length, total = 0;
for (int j=0; j < n; j += 2) total += arr[j]; return total; } 13)What is the time complexity of the following algorithm? (expressed in terms of n) Choose one of the important growth functions we covered in class: O(1), O(logn), O(n), O(nlogn), O(n2), O(n3), O(2n). public static int example3(int[ ] arr) { int n = arr.length, total = 0; for (int j=0; j < n; j++) for (int k=0; k <= j; k++) total += arr[j]; return total; }