Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Estimate the running time for the following program fragment in terms of n. Assu

ID: 3585498 • Letter: E

Question

Estimate the running time for the following program fragment in terms of n. Assume that the value of n is determined elsewhere in the program. Make your upper bound and lower bound as tight as you can. Please answer the following: 1, State an upper bound on the running time of the program fragment using notation. 2. Briefly justify your upper bound. State a lower bound on the running time of the program fragment using notation. 3. 4. Briefly justify your lower bound Even in cases where the upper bound and lower bound are the same function, the justifications would be different. (For upper bounds, you are claiming that the code will run no slower than the upper bound. For lower bounds, you are claiming that the code will take at least that amount of time.) Question 1: while (sum

Explanation / Answer

1. O(n)

2. The running time is 2+2n where 2n is for statements in while loop which will run n times. So it can be reduced to n+2n= 3n > 2+2n. So this is = O(n)

3. (n)

4. 2+2n > n So (n) as 2+2n will always be greater than n

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote