Solutions to some problems are intrinsically recursive, and writing them in an iterative fashion is difficult. The reverse also holds. Find an example or a recursive procedure and represent it as an iterative procedure. Also, choose an iterative procedure that you would re-write as recursive. What challenges did you face in the process? How did you go about resolving them?© BrainMass Inc. brainmass.com December 24, 2021, 8:31 pm ad1c9bdddf
An example of a recursive algorithm is computation of a power of 2.
Using recursive algorithm, we have:
power_2 (int n) //power_2 is a recursive function using the n, value of exponent, as argument.
if n = 0 //if n is 0, it will return the value of 1
This posting contains the answers to the given problems.