What is direct recursion


Discuss the below:

Q: a. What is direct recursion?

b. What is tail recursion?

c. Suppose hat intArray is an array of integers, and length specifies the number of elements in intArray. Also suppose that low and high are two integers such that 0 <= low < length. 0 <= high < length, and low < high. That is, low and high are two indices in intArray. Write a recursive definition that reverses the elements in intArray between low and high.

d. consider the following function.

int test(int x, int y)
{
if ( x == y)
return x;
else if (x > y)
return (x + y);
else
return test(x +1, y -1);
}

What is the ouput of the following statements?

1. cout << test(5, 10) << endl;

. cout << test(3, 9) << endl;

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: What is direct recursion
Reference No:- TGS01937464

Now Priced at $20 (50% Discount)

Recommended (92%)

Rated (4.4/5)