Question: Compare the following three algorithms. When is the algorithm of part la correct.? a . INPUT n , x 1 , x 2 , dots,

Compare the following three algorithms. When is the algorithm of part la correct.?
a. INPUT n,x1,x2,dots,xn.
OUTPUT PRODUCT.
Step 1 Set PRODUCT =0.
Step 2 For i=1,2,dots,n do
Set PRODUCT = PRODUCT **xi.
Step 3 OUTPUT PRODUCT; STOP.
b. INPUT n,x1,x2,dots,xn.
OUTPUT PRODUCT.
Step 1 Set PRODUCT =1.
Step 2 For i=1,2,dots,n do
Set PRODUCT = PRODUCT **xi.
Step 3 OUTPUT PRODUCT; STOP.
c. INPUT n,x1,x2,dots,xn.
OUTPUT PRODUCT.
Step 1 Set PRODUCT =1.
Step 2 For i=1,2,dots,n do
if xi=0 then set PRODUCT =0;
OUTPUT PRODUCT;
STOP
else set PRODUCT = PRODUCT **xi.
Step 3 OUTPUT PRODUCT; STOP.
 Compare the following three algorithms. When is the algorithm of part

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!