开发者

Any sites/books/tricks to practice recursion and OO design? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.

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!


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.


Sure, implement a binary tree and its operations


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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜