基础算法-递推法(Recursive algorithm).docVIP

  • 3
  • 0
  • 约1.17万字
  • 约 18页
  • 2017-10-06 发布于河南
  • 举报
基础算法-递推法(Recursive algorithm)

基础算法-递推法(Recursive algorithm) There is a class of questions, the changes between every two adjacent items have a certain regularity, we can put this rule into simple recursive formula as follows: Fn=g (Fn-1) This is the number in the sequence, establish the relationship between the antecedent and consequent, then from the initial condition (or end) to start, step by step according to the recursive relation of recursion, until the final results obtained (or initial value). Many programs are solved in this way. If a test, if we can find a relationship before and after a clear and its initial condition (end result), like to solve the problem, let the computer calculation is a step by step, let the computer do the high-speed repetitive operation, can really play the best use effect. Recursive, backward push and push two forms. General analysis idea: If solving condition F1 Then begin{inverted} The problem (or recursive relation) to determine the final result of Fa; For inverted formula Fi-1=g(Fi); I=n {{start} from the final result Fn While current results Fi non initial values F1 do are inverted by Fi-1=g (F1); Output push back results F1 and push backward process; End {then} Else, begin{, push,} The problem (or forward relationship) to determine the initial value of F1 (boundary conditions); Find the forward relation formula F1=g (Fi-1); I=1; {proceed from the boundary condition F1 {}} The results of Fi while do Fn non final results by Fi=g (Fi-1) CIS push back; The output of the Fn results and the pushing process; End; {else} I. backward pushing method The push down method, is not in the initial value of the case, by some recursive relations and informed the solution of the problem or goal, and then push down over, infer its initial conditions. Because the operations of such problems are mapped one by one, the recurrence formula can be analyzed. Then, from this solution or goal, take the push back section, step by step into the initial statement of the problem. Here

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档