本文介绍了什么时候应该优先考虑递归而不是c ++中的迭代?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,我正在阅读文章Iterative vs. Recursive Approaches,我发现迭代过程在这个场景中更可靠。



有人可以说我什么时候我们可以使用迭代而不是递归。



谢谢。



我尝试过:



显示的给定示例显示迭代appraoch的有效结果。我尝试过其他一些示例,但不是它也显示相同的结果。

Hello friends i was reading article "Iterative vs. Recursive Approaches" i found that iterative process is more reliable in this scenarion.

Can some one say me when can we use iteration over recurssion.

Thank you.

What I have tried:

The given example shown is shows efficient results for iterative appraoch.i have tried few of other example but not it also shows the same result.

推荐答案


Mustafa_ub2016写道:
Mustafa_ub2016 wrote:

有人可以说我什么时候可以使用迭代而不是递归。

Can some one say me when can we use iteration over recursion.

几乎每次都会遇到常见的问题。迭代变得非常复杂只有一些问题。

编写编译器时,通常使用递归,因为它是一个复杂的系统,需要从多个地方调用自己。

Almost every times for usual problems. There is only a few problems where iteration is getting really complicated.
When writing a compiler, recursion is commonly used because it is a complex system that need to call itself from multiple places.


这篇关于什么时候应该优先考虑递归而不是c ++中的迭代?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 01:52