有没有练习递归和面向对象设计的网站/书籍/技巧?

发布于 2024-10-08 17:51:58 字数 129 浏览 3 评论 0原文

我只是想知道是否有任何网站在练习递归和面向对象设计时存在问题(给定一些设计类/接口结构的实体)?

我毫无困难地理解需要递归的问题的解决方案,但我似乎无法将递归应用于新问题。有什么应用递归的技巧吗?如果这个问题很愚蠢,我深表歉意!

I just wanted to know if there are any sites which have problems for practicing recursion and OO design(given a few entities designing the class/interface structure)?

I understand the solutions to problems needing recursion without any difficulties but I can't seem to apply recursion to a new problem.Are there any tricks to apply recursion? I apologize if this question is very dumb!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

柒夜笙歌凉 2024-10-15 17:51:58

您可能需要查看诸如 Project EulerUSACO。它们提供了许多从简单到困难的问题,其中许多问题可以使用递归技术来解决。当您继续进行时,您将有机会了解其他人如何解决您尝试的问题。这样你不仅可以学习递归,还可以学习许多其他问题解决技术。

You may need to look at something like Project Euler or USACO. They provide many problems ranging from simple to hard and many of them can be solved using recursive techniques. As you proceed you will have a chance to see how others may have solved the problems that you attempt. This way you not only learn recursion but many other problem solving techniques.

橘和柠 2024-10-15 17:51:58

当然,实现一个二叉树及其操作

Sure, implement a binary tree and its operations

耶耶耶 2024-10-15 17:51:58

根据我的经验,递归最常用于更数学的算法设计,但在更高级别的编程(OOP 通常更高级别)中,递归的使用并不总是增加太多。此外,递归过程通常不容易适应,因此如果其中一个需求发生变化,可能会导致您重写整个过程,而在更线性的编程中,您可以更容易地添加或删除某些内容 - 它们的中间步骤不会彼此相互依赖。

此外,在(某些?)面向对象的语言中,对于每个递归级别,都会创建一个对象的新实例,这会导致开销。

这是一个值得了解的好技术,但根据问题的类型,您可能不会在现实生活中的 OO 问题中遇到太多使用它的情况。除了文件/目录脚本之外,出于性能或可维护性的原因,我基本上将大部分很酷的递归解决方案重写为无聊的线性解决方案。

In my experience, recursion is used most on more mathematical algorithm design, but in higher level programming (and OOP is usually higher level), the use of recursion doesn't always add much. Also, recursive procedures are usually not easily adapted, so if one of the requirements changes, it might cause you to rewrite the whole procedure, whereas in more linear programming you could easier get something in or leave it out - they intermediate steps don't depend on each other as much.

Also, in (some?) object oriented languages, for every level of recursion a new instance of an object is created and this causes overhead.

It's a nice technique to know, but depending on the sort of prolems, you might not encounter real life use of it much in OO problems. Apart from a file/directory script I've basically rewrote most of my cool recursive solutions to boring linear ones for performance or maintainability reasons.

第七度阳光i 2024-10-15 17:51:58

尝试 http://programmingpraxis.com

它有关于递归示例的问题/

示例:编写一个从以下位置打印数字的递归程序1 到 10,斐波那级数

try http://programmingpraxis.com

It has got questions/sample examples on recursion

example:write a recursive program that prints numbers from 1 to 10,fibonnaic series

惯饮孤独 2024-10-15 17:51:58

您遇到什么问题?我建议鉴于其中一个新问题,你还有一次机会。如果您无法让它工作,请发布一个简单的示例,说明您拥有的内容以及您正在尝试执行的操作,别人可能会看到哪个部分使您陷入困境。

What problems are you running into? I would suggest given one of the new problems you have another chance. If you can't get it to work post a simple example of what you have and what you are trying to do and someone might be able to see what part is tripping you up.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文