Discrete Mathematics

posted by .

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 -

    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 -

    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

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. AED

    Post your response to the following: The introduction of calculators and computers into the mathematics classroom has made it faster and easier for students to complete difficult problems. Technology should not, however, replace the …
  2. algebra 1

    ELEMENTARY ALGEBRA #3 Page 23 Chapter 3 Lesson 3.02 Solving Multi-step Equations Reading Assignment: Study pages 126 – 129 Written Assignment: There are five steps to solve Multi-Step equations, Match them in their proper order. …
  3. Math

    Use multiplication, division, addition and subtraction and at least one set of parentheses to write an expression that simplifies to 7, 13, or 17. Do your work step by step and explain each step as you simplify the expression. Demonstrate …
  4. pre algebra

    solve the equation step by step.list each step along with the property you used during that step. -5 x 1 x 11 x 4
  5. algerbra

    solve the equation step by step list each step along with the property you used during that step -5*1*11*4
  6. ALGEBRA HELP

    When solving the equation, what property was used to go from step 3 to step 4?
  7. chemistry

    1)Thallium (I) is oxidized by cerium (IV) as follows: Tl+ + 2 Ce+4  Tl+3 + 2 Ce+3 The elementary steps, in the presence of Mn(II), are as follows: Step 1 Ce+4 + Mn+2 --- Ce+3 + Mn+ Step 2 Ce+4 + Mn+3 ---- Ce+3 + Mn+4 Step 3 …
  8. MAth

    2+3m=17 7 6 10 5 use inverse operations to solve each equation. Explain each step and identify the propaty used to reach steps. 19=h/3-8 solve the equation : expiation each step and identify the property used to reach each step 0.6x+0.8=1.4 …
  9. MAth

    2+3m=17 7 6 10 5 use inverse operations to solve each equation. Explain each step and identify the propaty used to reach steps. 19=h/3-8 solve the equation : expiation each step and identify the property used to reach each step 0.6x+0.8=1.4 …
  10. ONE math question! Check please, thank you!

    6) 108 is 36% of what number? Write and solve a proportion to solve the problem. Step 1. First, I will write the proportion to find the missing value, which I will replace it with n. 108/n = 36/100 Step 2. Next, I will write the cross

More Similar Questions