Can every recursion be converted into iteration?

前端 未结 17 2316
遥遥无期
遥遥无期 2020-11-22 01:59

A reddit thread brought up an apparently interesting question:

Tail recursive functions can trivially be converted into iterative functions. Other one

17条回答
  •  别那么骄傲
    2020-11-22 02:09

    Have a look at the following entries on wikipedia, you can use them as a starting point to find a complete answer to your question.

    • Recursion in computer science
    • Recurrence relation

    Follows a paragraph that may give you some hint on where to start:

    Solving a recurrence relation means obtaining a closed-form solution: a non-recursive function of n.

    Also have a look at the last paragraph of this entry.

提交回复
热议问题