Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(1 point) Check ALL correct statments about the following algorithms procedure d

ID: 3199110 • Letter: #

Question

(1 point) Check ALL correct statments about the following algorithms procedure double(n: positive integer) while n 0 begin end output(n) A. This algorithm lacks finiteness B. When n-5 is the input, n-10 is the final output of the algorithm. C. When n-5 is the input, the while loop is infinite procedure divide(n: positive integer) while n>0 begin m1n n:= n-1 end output(m) ) A. This algorithm lacks detinateness since division by zero occurs B. This algorithm works and outputs 1/n. C. When n-1 is the input, on the second iteration of the while loop a division by zero occurs D. When n-1 is the input, after the first iteration of the while loop we have m-1 and n-0 E. When n? Is the input, the agonthm exits the while loop after the first iteration and outputs m=1 F. This algorithm works and always outputs 1 procedure sum(n: positive integer) sum := 0 while i

Explanation / Answer

1.It will result in a infinite loop because

n will keep on multiplying as the while loop condition holds good in all the cases.

so answers :- A,C

2. This algorithm results in division by zero and when n =1 in second iteration it leads to division by zero,and after first iteration m = 1 and n = 0

so answers :- A,C,D

3.here even though the i value is initiated , it not at all increamented in the loop and hence it leads to infinite loop.

and this algorithm doesnt use the input n

so answers :- B,D,F