Question

Several algorithms have a loop structure that iterates n times and for the k-th iteration, they perform on the order of k2 operations. In this case, the running time of the loop can be obtained by k2. In this problem, we will derive a closed formula for this sum and show that the sum is O(ui) 1. A telescoping sum is a sum of the form Σ-i (aj - a-1). It is easy to see that this sum equals an -do (try it for example for j 4). In class, we stated that ΣΑι k-n(n + 1 )(2n + 1 )/6. Derive this formula using the telescoping sum. Hint: Take ak-: k 3 in the telescoping sum. 2. Show that () by explicitly finding the values of the constants k and C and demonstrating the result.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

1) Telescopic stu n: 1) (2n ) 6 k-1 Proof: The above can be proved by using the principle of mathematical induction. For example, N-1:1211*(1+1)* (2*1+1)/6. It is true for the values such that 12+ 242+312+N2 N*N1) (2N+1)/6, Add (N+12 on both sides (12+ 242+312+ +N2)+ (N+12 N*N+1) (2N+1)/6 +(N+1)2, 1^2+ 22 + 32 + + N^2+ (N-1)^2 = (N+1)* [N*(2*N-1)/G+ N +1], N+1) 2*N 2+7*N+6)/6, (N+1)*[(N-IHI]*[2*(N-1)+1]/6. This is the statement need to prove for N+1. Apply here the principle of mathematical induction to conclude the statement for all the values N>1.

The another approach is that a(n)= N*(N+1)*(2N+1)/6. N*L(2 N 2+3*N+1)-(2 NA2-3*N+1)]/6, N* (69)/6. Let apply, 112 f(1) - f(0), 22 f(2) - f(1), 3n2 f(3) f(2), (N-1)^2-a(N-1)-a(N-2), While adding all those together, there will be cancellation of terms on right side. After cancellation, the term will be 12 22 +32 +... + N2-a(n)-a(0)- N*(N+1) (2N+1)/6 This is a big cancellation that occurs in a sum and this type of cancellation is referred as telescoping sum. From the above steps, the telescopic sum of first N squares 1) (2n ) 62) It is need to prove that k 1 Since, result of telescopic sum of first N squares results in Ση_1 k-n (n + 1) (2n +1) / 6 While multiplying the terms on right side in above result of telescopic sum, it will results in n2 N*N-) 2N+1)6 polynomial which is higher order term in the polynomial expression This higher order notation is to represent the time complexity. So, according to big-oh notation, the running time for telescopic sum of first N squares is O(n3) Hence, it is proved O(n) k-1

Add a comment
Know the answer?
Add Answer to:
Several algorithms have a loop structure that iterates n times and for the k-th iteration, they...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT