Q25: Recursion vs. Iteration

Recursive solutions arise when there’s a scope of expressing the solution of a problem in terms of simpler versions of the same problem. Iterative solutions on the other hand simply keep repeating a same task until it’s “done”.

Question #25: Which of the following statements is false in relation to recursion & iterative solutions?

Options:

A) Recursion may provide a nice elegant mathematical solution to a particular problem, but it might not be the most efficient approach to solving the problem on a computer.

B) It is always possible to convert a recursion into an iterative solution.

C) Some recursive solutions can’t be expressed iteratively.

D) Some data structures like trees are easier to explore using recursion.

Solution: In some cases, recursive solutions have a higher time & space complexity than iterative ones, so statement A is correct. It is also true that all recursive solutions can be expressed as iterative ones.  Trees are an example of data structures which are more intuitively explored using recursion. Tree traversal, lookup algorithms are neatly expressed recursively. Hence, option C is the correct choice.