Computer Science, asked by dharmik2518, 8 days ago

which version of algorithm is preferred when memory resources are limited Iterative or recursive? Justify your answer.​

Answers

Answered by bhaleuday30
5

Answer:

There are two main differences considering iteration and recursion. The first one is about the number of cycles that are needed to complete the operation. while the second one concerns the alignment of navigation and operation segment of the algorithm. With an iterative approach the maximum number of cycles has to be known prior the iteration starts and operational and navigational parts of the algorithm are aligned (navigation and operation parts are at the same level of iteration). With an recursive approach the maximum number of cycles need not be known prior the launching and depends of the navigation part stop criteria of the algorithm. Also the navigation and operation part of the algorithm are not aligned because the operation is performed after navigation finishes (while algorithm is "returning" from the recursion).

Answered by aryansuts01
0

Answer:

Iteration utilizes less memory than recursion. The code gets smaller due to recursion. Without the expense of system calls or the utilization of stack memory, iteration can be used to continuously run a group of instructions. Iteration is faster and more efficient than recursion. Iterative codes often have polynomial time complexity and are simpler to optimize.

Explanation:

In comparison to iteration, recursion consumes greater memory. Up until the base condition is false in recursion, the procedure will call himself. Recursion will therefore call itself up until the base condition is false, much like a loop. Recursion uses more memory, whereas iteration uses less.

whenever designing a recursive method is simpler. situations where a problem can be split up into several smaller, identical problems. Both recursion & iteration are used to carry out the set of instructions constantly. Recursion occurs when a statement within a function continuously invokes itself. A loop iterates whenever it runs repeatedly until the underlying condition fails. Recursion & iteration vary primarily in that iteration applies to a series of commands that we want to run again whereas recursion is a procedure that is always applied to a function. Select pattern is used in recursion.

  • If the problem is not reduced in a way that conforms on a certain circumstance (base case), endless recursion takes place, and endless
  • recursion might cause the system to fail.
  • A base case is identified when recursion comes to an end.
  • Because of the expense involved in maintaining the stack, recursion is generally slower than iteration.
  • Iteration utilises less memory than recursion.
  • The code gets smaller due to recursion.

#SPJ3

Similar questions