How to recognize what is, and what is not tail recursion?

后端 未结 4 1882
终归单人心
终归单人心 2020-12-29 09:47

Sometimes it\'s simple enough (if the self call is the last statement, it\'s tail recursion), but there are still cases that confuse me. A professor told me that \"if there\

4条回答
  •  鱼传尺愫
    2020-12-29 10:50

    Yep; I think your professor meant that in any path, if the final instruction is recursive, then it is tail recursion.

    So, all three examples are tail-recursive.

提交回复
热议问题