Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you explain how to find the answers to 1 and 4? I don't understand how to apply the hinted formula. ( begin{array}{ll}text { //

Can you explain how to find the answers to 1 and 4? I don't understand how to apply the hinted formula.

image text in transcribedimage text in transcribed

\( \begin{array}{ll}\text { // Prerequisite: } n>=0 . & \\ \text { int twiddle_thumbs(int } n)\{ & \\ \quad \text { int } i=0 ; & / / \text { Line } 1 \\ \quad \text { int result }=8 ; & / / \text { Line } 2 \\ \text { int } p=10 ; & / / \text { Line } 3 \\ \text { while }(pi,p, and n for this problem. As you analyse this, you will probably want to write out a formula for result first using or notation! Note that i is there just for convenience to help you count the number of times we've gone through the loop! Now, answer the following questions about the code: 1. Finish this to make a (correct and descriptive) invariant on result: Just before each iteration of the loop, expressed in terms of i, result is equal to exactly: 5i2+5i+8 Hint: You may find it helpful to remember that k=1jk=2j(j+1). 4. In terms of n, the exact final value of result is: 20n2+10n+8

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 2005 Databases

Authors: Karli Watson

1st Edition

0470044063, 978-0470044063

More Books

Students also viewed these Databases questions

Question

e. What do you know about your ethnic background?

Answered: 1 week ago

Question

b. Why were these values considered important?

Answered: 1 week ago