Advantages & Disadvantages of Recursion

Recursion is a technique in which a problem is solved by itself; it's a technique to solve most Divide & Conquer problems.

Differences between Divide & Conquer problem and Dynamic Programming problem:

Sub-problems of DP usually have some relations, while Divide & Conquer is not.

Advantages

  • Easy to understand.

Disadvantages

  • Usually slower than iteration
  • Stack overflow risk: Each step will recursively call a function, which will significantly occupy a lot stack memory.
  • Difficult to debug and trace value.

 

Guess you like

Origin www.cnblogs.com/ireneyanglan/p/11371286.html