Question: . (Recursive Exponentiation) Write a recursive function power(base, exponent) that when invoked returns base exponent For example, power(3, 4) = 3 * 3 * 3
. (Recursive Exponentiation)
Write a recursive function power(base, exponent) that when invoked
returns
base
exponent
For example, power(3, 4) = 3 * 3 * 3 * 3
. Assume that exponent is an integer greater than or equal to 1.
Hint:
The recursion step would use the relationship
base
exponent
= base *
base
exponent
-
1
and the terminating condition occurs when exponent is equal to 1 because
base
1
= base
2.
(
Recursive Greatest Common Divis
or)
The greatest common divisor of inte
gers x and y is the largest
integer that evenly divides both x and y. Write a recursive function gcd that returns the greatest common
divisor of x and y. The gcd of x and y is defined recursively as follows: If y is equal to 0, then gcd(x, y) is
x; otherw
ise gcd(x, y) is gcd(y, x % y), where % is the remainder operator.
3.
(Find the Minimum Value in an array)
Write a recursive function recurs
iveMinimum
that takes an
integer array and the array size as arguments and returns the smallest element of the array. The function
should stop proces
sing and return when i
t receives an array of one element.
4.
Write the
int main(void)
function as a driver program and call the above
three
functions result with
sample Input/Output.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
