What is the time complexity o

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; }

Complete Answer:

Get Instant Help in Homework Asap
Get Instant Help in Homework Asap
Calculate your paper price
Pages (550 words)
Approximate price: -
Open chat
1
Hello 👋
Thank you for choosing our assignment help service!
How can I help you?