1. Computer Science Engineering (CSE)
  2. Design and Analysis of Algorithms
  3. What is the advantage of iterative code ...
Q.

What is the advantage of iterative code for finding power of number over recursive code?

A. iterative code requires less time
B. iterative code requires less space
C. iterative code is more compiler friendly
D. it has no advantage
Answer» B. iterative code requires less space
Explanation: both iterative and recursive approach can be implemented in log n time but the recursive code requires memory in call stack which makes it less preferable.

Discussion