If a recursion call is the last executable statement in the algorithm, called tail recursion, it can easily be removed using iteration. Tail recursion is so named because the return point of each call...


If a recursion call is the last executable statement in the algorithm, called tail recursion, it can easily be removed using iteration. Tail recursion is so named because the return point of each call is at the end of the algorithm. Thus, there are no executable statements to be executed after each call. To change a tail recursion to an iteration, we use the following steps:


a. Use a variable to replace the procedure call.


b. Use a loop with the limit condition as the base case (or its complement).


c. Enclose all executable statements inside the loop.


d. Change the recursive call to an appropriate assignment statement.


e. Use appropriate statements to reassign values to parameters.


f. Return the value of the variable defined in step a.



Dec 20, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here