資源描述:
《基礎算法遞推法(Recursive algorithm)》由會員上傳分享,免費在線閱讀,更多相關內(nèi)容在學術論文-天天文庫。
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