# Answer on Discrete Mathematics Question for Sandra

Question #2250

How many elementary operations are used in the following algorithm?

Step 1 Set S = a, k = 1, 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 3 Print S

Step 1 Set S = a, k = 1, 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 3 Print S

Expert's answer

Step 1: 3 operations (3 "=");

Step 2: 6(n-1) + n = 7(n-1) + 1& operations ((n-1)*(3 "=", 3 "+") and& n checkings if k<n).

Step 3 : print() is not elementary operation.

Thus:& 3 + 7(n-1)+1& = 7(n-1) + 4.

Step 2: 6(n-1) + n = 7(n-1) + 1& operations ((n-1)*(3 "=", 3 "+") and& n checkings if k<n).

Step 3 : print() is not elementary operation.

Thus:& 3 + 7(n-1)+1& = 7(n-1) + 4.

Need a fast expert's response?

Submit orderand get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

## Comments

## Leave a comment