Open In App

ISRO | ISRO CS 2018 | Question 79

Last Updated : 06 Jul, 2018
Like Article
Like
Save
Share
Report

Let P be a procedure that for some inputs calls itself (i.e. is recursive). If P is guaranteed to terminate, which of the following statement(s) must be true?

I.   P has a local variable
II.  P has an execution path where it does not call itself
III. P either refers to a global variable or has at least one parameter

(A) I only
(B) II only
(C) III only
(D) II and III only


Answer: (D)

Explanation: In any recursive procedure:
a) A base condition is always required, so that, the procedure can terminate its repeated execution while returning some value to the main() function. So, statement (II) is necessary.
b) a recursive function should either refers to a global variable or has at least one parameter so that it can be recursively called creating a new copy of local variables in the stack. In the absence of these, there would be no purpose of a recursive procedure as it will not be able to execute.

So, option (D) is correct.

Quiz of this Question


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads