How many elementary operations are used in the following alg

How many elementary operations are used in the following algorithm? The elementary operations are comparison operations (such as > and <) and mathematical operations (such as addition, subtraction, multiplication, division, etc.).

Step 1 Set a = 1, b = 1 c = 2, and k = 1.

Step 2 while k < n

(a) Replace c with a+b

(b) Replace a with b

(c) Replace b with c

(d) Replace k with k+1

endwhile

Step 3 Print b.

Solution

4 elementary operations are used here.

How many elementary operations are used in the following algorithm? The elementary operations are comparison operations (such as > and <) and mathematical

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site