设计模式转换递归算法迭代的人

编程入门 行业动态 更新时间:2024-10-12 05:49:31
本文介绍了设计模式转换递归算法迭代的人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否有任何一般的启发,提示,技巧,或常见的设计范例,可以用来递归算法转换为一个迭代?我知道这是可以做到的,我不知道是否有做法值得做的事情,所以当牢记。

Are there any general heuristics, tips, tricks, or common design paradigms that can be employed to convert a recursive algorithm to an iterative one? I know it can be done, I'm wondering if there are practices worth keeping in mind when doing so.

推荐答案

您可以经常完全preserve递归算法的原始结构,但要避免堆栈,采用尾调用和更改为 continuation-通过,所建议的此博客条目。 (我真的应该煮了更好的独立的例子。)

You can often entirely preserve the original structure of a recursive algorithm, but avoid the stack, by employing tail calls and changing to continuation-passing, as suggested by this blog entry. (I should really cook up a better standalone example.)

更多推荐

设计模式转换递归算法迭代的人

本文发布于:2023-11-30 14:28:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1650325.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:递归   的人   算法   模式   迭代

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!