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.

 

posted @ 2019-08-18 04:20  树獭君  阅读(140)  评论(0)    收藏  举报