欢迎来到天天文库
浏览记录
ID:37708763
大小:58.50 KB
页数:11页
时间:2019-05-29
《chapter14_6e》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、TestBankforProblemSolvingwithC++:TheObjectofProgramming,6/eChapter14RecursionTRUE/FALSE1.Therecanbemorethanonestoppingcaseinarecursivefunction.ANSWER:TRUE2.Youmayhaveatmost1recursivecallinarecursivefunction.ANSWER:FALSE3.Recursivefunctionsmustreturnavalue.ANSWER:FALSE4.Theoperating
2、systemusesastacktocontrolrecursion.ANSWER:TRUE5.Aclassmemberfunctionmayberecursive.ANSWER:TRUE6.RecursivefunctionsmayreturnanytypeofvalueANSWER:TRUE7.Notallrecursivedefinitionsmaybewritteniteratively.ANSWER:FALSE8.Recursivefunctionsalwaysexecutefasterthananiterativefunction.ANSWER:
3、FALSE9.Onlyfunctionsthatdonotreturnavaluemayberecursive.ANSWER:FALSE10.Everyrecursivedefinitionmayberewritteniteratively.ANSWER:TRUEShortAnswer1.Arecursivefunctionisafunctionthat______________.ANSWER:callsitself2.Astackexhibitswhatbehavior?ANSWER:LastIn–FirstOut3.Inarecursivefuncti
4、on,thestatement(s)thatinvokethefunctionagainarecalledthe______________.ANSWER:recursivecalls4.Iftherecursivefunctioncalldoesnotleadtowardsastoppingcase,youhave______________.ANSWER:infiniterecursionorastackoverflow5.Howdoyouensurethatyourfunctiondoesnothaveinfiniterecursion?ANSWER:
5、Allrecursivecallsmustleadtoastoppingcase.6.Whatistheoutputofthefollowingcodefragment?intf1(intbase,intlimit){if(base>limit)return-1;elseif(base==limit)return1;elsereturnbase*f1(base+2,limit);}TestBankforProblemSolvingwithC++:TheObjectofProgramming,6/eChapter14Recursionintmain(){cou
6、t<7、8、y<0)returnx-y;elsereturnf1(x-1,y)+f1(x,y-1);}intmain(){cout<9、power,atwhatvalueofexpdoyoustop?Thefunctionwillcontinuallymultiplythebasetimesthevaluereturnedbythepowerfunctionwiththebaseargumentonesmaller.ANSWER:exp=13.Inarecursivepowerfunctionthatcalculatessomebasetotheexppower,whatistherecursivecall?ANSWER:returnbase*power(base,exp-1);4.Fore10、veryrecursivesolution,ther
7、
8、y<0)returnx-y;elsereturnf1(x-1,y)+f1(x,y-1);}intmain(){cout<9、power,atwhatvalueofexpdoyoustop?Thefunctionwillcontinuallymultiplythebasetimesthevaluereturnedbythepowerfunctionwiththebaseargumentonesmaller.ANSWER:exp=13.Inarecursivepowerfunctionthatcalculatessomebasetotheexppower,whatistherecursivecall?ANSWER:returnbase*power(base,exp-1);4.Fore10、veryrecursivesolution,ther
9、power,atwhatvalueofexpdoyoustop?Thefunctionwillcontinuallymultiplythebasetimesthevaluereturnedbythepowerfunctionwiththebaseargumentonesmaller.ANSWER:exp=13.Inarecursivepowerfunctionthatcalculatessomebasetotheexppower,whatistherecursivecall?ANSWER:returnbase*power(base,exp-1);4.Fore
10、veryrecursivesolution,ther
此文档下载收益归作者所有
点击更多查看相关文章~~