# Iterative and Recursive Algorithms

Not what you're looking for? Search our solutions OR ask your own Custom question.

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 March 7, 2023, 3:34 am ad1c9bdddfhttps://brainmass.com/computer-science/algorithms/iterative-and-recursive-algorithms-284883

#### Solution Preview

Hi,

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

return 1;

...

#### Solution Summary

This posting contains the answers to the given problems.

$2.49