资源描述:
《基础算法递推法(Recursive algorithm)》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、基础算法-递推法(Recursivealgorithm)Thereisaclassofquestions,thechangesbetweeneverytwoadjacentitemshaveacertainregularity,wecanputthisruleintosimplerecursiveformulaasfollows:Fn=g(Fn-1)Thisisthenumberinthesequence,establishtherelationshipbetweentheantecedentandconsequent,thenfromtheini
2、tialcondition(orend)tostart,stepbystepaccordingtotherecursiverelationofrecursion,untilthefinalresultsobtained(orinitialvalue).Manyprogramsaresolvedinthisway.Ifatest,ifwecanfindarelationshipbeforeandafteraclearanditsinitialcondition(endresult),liketosolvetheproblem,letthecomput
3、ercalculationisastepbystep,letthecomputerdothehigh-speedrepetitiveoperation,canreallyplaythe"bestuse"effect.Recursive,backwardpushandpushtwoforms.Generalanalysisidea:IfsolvingconditionF1Thenbegin{inverted}Theproblem(orrecursiverelation)todeterminethefinalresultofFa;Forinverted
4、formulaFi-1=g'(Fi);I=n{{start}fromthefinalresultFnWhilecurrentresultsFinoninitialvaluesF1doareinvertedbyFi-1=g(F1);OutputpushbackresultsF1andpushbackwardprocess;End{then}Else,begin{,push,}Theproblem(orforwardrelationship)todeterminetheinitialvalueofF1(boundaryconditions);Findt
5、heforwardrelationformulaF1=g(Fi-1);I=1;{proceedfromtheboundaryconditionF1{}}TheresultsofFiwhiledoFnnonfinalresultsbyFi=g(Fi-1)CISpushback;TheoutputoftheFnresultsandthepushingprocess;End;{else}I.backwardpushingmethodThepushdownmethod,isnotintheinitialvalueofthecase,bysomerecurs
6、iverelationsandinformedthesolutionoftheproblemorgoal,andthenpushdownover,inferitsinitialconditions.Becausetheoperationsofsuchproblemsaremappedonebyone,therecurrenceformulacanbeanalyzed.Then,fromthissolutionorgoal,takethepushbacksection,stepbystepintotheinitialstatementofthepro
7、blem.Herearesomeexamples.[1]oilstoragepointAheavytruckwantstocross1000kilometersofdesert,andthetruckuses1liters/kmoffuel,andthetotalcapacityofthetruckis500liters.Obviously,atrucknevergetsthroughthedesertatonetime.Asaresult,driversmusttrytosetupseveralstoragepointsalongthewayso
8、thattruckscancrossthedesertsmoothly.Howcandriversbuildtheseoi