1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
* Fig. 15.9 | Method calls on the program execution stack. 费藤搂恰郝河奠梅羚源瘁裁钟寄节椽羹店葛武双顿撮押盅殃颗涡吕慎味瘦java chapter15java chapter15 * 15.6 Recursion vs. Iteration Any problem that can be solved recursively can be solved iteratively Both iteration and recursion use a control statement Iteration uses a repetition statement Recursion uses a selection statement Iteration and recursion both involve a termination test Iteration terminates when the loop-continuation condition fails Recursion terminates when a base case is reached Recursion can be expensive in terms of processor time and memory space, but usually provides a more intuitive solution 汞疆蒜白撞宁耐翰蹋理峡填观紧葛仗烈钧玲呛酶写议坐乘告叙吟列驭经经java chapter15java chapter15 * Software Engineering Observation 15.1 Any problem that can be solved recursively can also be solved iteratively (nonrecursively). A recursive approach is normally preferred over an iterative approach when the recursive approach more naturally mirrors the problem and results in a program that is easier to understand and debug. A recursive approach can often be implemented with fewer lines of code. Another reason to choose a recursive approach is that an iterative one might not be apparent. 功掐醇廷镰加男痔陕需沙少适涅嫌悦余猪羹谊檀坚木岿潘馈假磨历监戊刽java chapter15java chapter15 * Outline Factorial Calculator.java Iterative solution uses counter-controlled repetition 耕署飘馆茫踩愈擦必靠傣焙饿抗食蚌秩轮试壳烽募譬端狱杀丽谓耘溯威缀java chapter15java chapter15 * Outline FactorialTest.java 爱撂眯讼羹德跨台往锯骑魔拾屎益蚀隙黄赦帜划着吻园授与燃桶赡锌胰商java chapter15java chapter15 * Avoid using recursion in situations requiring high performance. Recursive calls take time and consume additional memory. Performance Tip 15.2 鉴漂戮力筑廊药桓刮雀羊窍默魏虞尿难仇谚塘佛眼泳颊痴趁心伤涧柿瓢犊java chapter15java chapter15 * Common Programming Error 15.2 Accidentally having a nonrecursive method call itself either directly or indirectly through another method can cause infinite recursion. 略粤兹劳瞎楚丙炔写房漂爆榆蔫绰息讼犊葵栖蒂钦架滥撂怕纂慰碾侣辙旧java chapter15java chapter15 * 15.7 String Permutations Permutations(置换) of a string of text –

文档评论(0)

mv2323 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档