本文介绍了我可以要求物理类比或隐喻递归吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我突然在一个递归语言类(sml)中,递归对我来说还不是很理智。我正在想方形瓷砖的地板有时是整数倍增的模型或隐喻,或者Cuisenaire棒是加法和减法的模型或类比。有没有人有这样的模型可以分享?

解决方案

想象一下,你是一个真正的魔术师,你自己。你创造了一个更接近目标的步伐,并给予他(或她)与你所得到的相同的命令

你的双倍对他的副本也一样。他是魔术师,你看。



当最终版本发现自己创建了目标时,它无处可去,所以它向其创建者报告。这是相同的。



最后,你可以回答– 没有移动过一英寸 –现在可以轻松地从中创建最终结果。你假装不知道所有那些为你做实际的辛苦工作的双打。 嗯,你对自己说,如果我离目标更近了一步, 已经知道 结果?难道 很容易 找到最终答案 然后



当然,如果 you 是双重的,您必须将您的发现报告给 创建者。



更多。 (也是,我认为我看到这个双打创作连锁事件,虽然我不完全确定)。






Of course, if you were a double, you'd have to report your findings to your creator.

More here.

(also, I think I saw this "doubles" creation chain event here, though I'm not entirely sure).


and that is the essence of the recursion method of problem solving.

How do I know my procedure is right? If my simple little combination step produces a valid solution, under assumption it produced the correct solution for the smaller case, all I need is to make sure it works for the smallest case – the base case – and then by induction the validity is proven!

Another possibility is divide-and-conquer, where we split our problem in two halves, so will get to the base case much much faster. As long as the combination step is simple (and preserves validity of solution of course), it works. In our magician metaphor, I get to create two copies of myself, and combine their two answers into one when they are finished. Each of them creates two copies of themselves as well, so this creates a branching tree of magicians, instead of a simple line as before.


A good example is the Sierpinski triangle which is a figure that is built from three quarter-sized Sierpinski triangles simply, by stacking them up at their corners.

Each of the three component triangles is built according to the same recipe.

Although it doesn't have the base case, and so the recursion is unbounded (bottomless; infinite), any finite representation of S.T. will presumably draw just a dot in place of the S.T. which is too small (serving as the base case, stopping the recursion).

There's a nice picture of it in the linked Wikipedia article.

Recursively drawing an S.T. without the size limit will never draw anything on screen! For mathematicians recursion may be great, engineers though should be more cautious about it. :)

Switching to corecursion ⁄ iteration (see the linked answer for that), we would first draw the outlines, and the interiors after that; so even without the size limit the picture would appear pretty quickly. The program would then be busy without any noticeable effect, but that's better than the empty screen.

这篇关于我可以要求物理类比或隐喻递归吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 21:01