Posted by **Compstudent** on Wednesday, March 30, 2011 at 10:10pm.

How many elementary operations are used in the following algorithm?

Step 1 Set S = a, k = 0 , and t = a

Step 2 while k < n

(a) Replace t with t+d

(b) Replace S with S+t

(c) Replace k with k+1

endwhile

Step 2 Print S

------------------------

My answer was: 4*n+1

I don't know if it is right :(

- Discrete Mathematics -
**bobpursley**, Wednesday, March 30, 2011 at 10:52pm
if k=>n, there is only one operation, the test.

If k<n, then each time the test occurs, there are four operations(test, replace, replace, replace), and one final operation the test.

4n+1 is correct.

- Discrete Mathematics -
**Karen**, Sunday, June 26, 2011 at 7:04pm
Step 1 Set a=1, b=1, c=2,and k=0

Step 2 while k < n

(a) Replace c with a+b

(b) Replace a with b

(c) Replace k with k+1

endwhile

Step 3 Print b

## Answer This Question

## Related Questions

- ALGEBRA HELP - When solving the equation, what property was used to go from step...
- AED - Post your response to the following: The introduction of calculators and ...
- Math - Use multiplication, division, addition and subtraction and at least one ...
- ONE math question! Check please, thank you! - 6) 108 is 36% of what number? ...
- MAth - 2+3m=17 7 6 10 5 use inverse operations to solve each equation. Explain ...
- MAth - 2+3m=17 7 6 10 5 use inverse operations to solve each equation. Explain ...
- pre algebra - solve the equation step by step.list each step along with the ...
- algebra 1 - ELEMENTARY ALGEBRA #3 Page 23 Chapter 3 Lesson 3.02 Solving Multi-...
- algerbra - solve the equation step by step list each step along with the ...
- chemistry - 1)Thallium (I) is oxidized by cerium (IV) as follows: Tl+ + 2 Ce+4...

More Related Questions