24.8k views
5 votes
When mehtod X calls method Y , method Y called methhod Z, and method Z calles method X, this is called

A. An error

B. Mutual recursion

C.tail recursion

D.indirect recursion

1 Answer

3 votes

Answer:

D.Indirect Recursion.

Step-by-step explanation:

Indirect recursion is when a method calls other method which calls the original method again.

For example:-

public static int mthd1( int n)

{

if (n == 0)

return 0;

else

return (mthd2(n-1));

}

public static int mthd2(int n2)

{ return mthd1( n2-1); }

This is an example of indirect recursion.Where mthd1 calls mthd 2 and mthd 2 calls mthd 1 again.

User Dragonroot
by
5.4k points