Compute for the time complexity with solution int cTotal(int n){ int i; int total=0; for (i=1; i <= n ; i++)

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Compute for the time complexity with solution int cTotal(int n){ int i; int total=0; for (i=1; i <= n ; i++)

Post by answerhappygod »

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]
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply