How many elementary operations are used in the following


1) Use the method of Iteration to find a formula expressing S(n) as a function of n for the given recurrence relation and initial condition: S(n) = S(n-1) - 3, S(0)=5.

2) 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 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 3: Print S.

3) 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 Preview :

Prepared by a verified Expert
C/C++ Programming: How many elementary operations are used in the following
Reference No:- TGS01248133

Now Priced at $20 (50% Discount)

Recommended (91%)

Rated (4.3/5)