Compute for the time complexity with solution
int cTotal(int n){
int i;
int total=0;
for (i=1; i <= n ; i++)
total += i;
return total;
}
• What is T(n) [worst case senario]
• What is T(n) if i<=n change to i<n
• What is T(n) if instead of returning the sum of n, it will
return only the sum of all even numbers from 1 to n [worst case
senario]
Compute for the time complexity with solution int cTotal(int n){ int i; int total=0; for (i=1; i <= n ; i++)
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am