ImageVerifierCode 换一换
格式:DOCX , 页数:9 ,大小:18.77KB ,
资源ID:4120950      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/4120950.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(基础算法递推法Recursive algorithm.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

基础算法递推法Recursive algorithm.docx

1、基础算法递推法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 betwee

2、n 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 cl

3、ear 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

4、F1Then begininvertedThe 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 FnWhile 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 thenEl

5、se, 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

6、 results and the pushing process;End; elseI. backward pushing methodThe 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 probl

7、ems 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 are some examples.1 oil storage pointA heavy truck wants to cross 1000 kilometers of desert, and the truck uses

8、 1 liters / km of fuel, and the total capacity of the truck is 500 liters. Obviously, a truck never gets through the desert at one time. As a result, drivers must try to set up several storage points along the way so that trucks can cross the desert smoothly. How can drivers build these oil storage

9、points? How much oil should be stored at each point to make the truck pass through the desert at the expense of least oil?Algorithm analysis:Oil storage point number calculation program and print the establishment, the oil storage from the edge of the desert of the distance and the storage of oil.No

10、. Distance (K.M.) oil (litre)1, X, X, X, X2, X, X, X, X3, X, X, X, X.Set disi as the distance between the I oil storage point and the end point (i=0);Oili is the storage quantity of the I oil storage points;We can solve this problem by the back pushing method. From the end to the beginning of the pu

11、sh down, one by one to find the location of each oil storage point and the amount of oil storage.But when the return point are shown:The strategy of pushing back from the oil storage point I to the oil storage point i+1 is that the truck moves back and forth between point I and point i+1. Each time

12、the truck returns to i+1, it runs out of 500 liters of gasoline, and each time it leaves the i+1, it has to hold 500 liters of gasoline. The distance between the two points must satisfy the I point i*500 gasoline fuel storage at least the requirements (0=i=1000;Disk: =1000; starting point to end dis

13、tance valueD1:=1000-disk-1 = i=n to start pointOilk: =d1* (2*k+1) +oilk-1; start point oil storageFor i:=0 to k do start from the start point, print the starting point to the distance from the current oil storage point and the amount of oil storageWriteln (I, 1000-disk-i: 30, oilk-i: 80);End. mainCo

14、nverts to the C language program as follows:#includeVoid, main ()Int k; / * * / oil storage location numberFloat D, D1 /*d:; the cumulative end point to the current oil storage point distance, d1:i=n distance to the starting point.Float, oil10, dis10;Int i;Printf (NO. distance (K.M.) toil (L.) n);K=

15、1;D=500; / * * / starting point began to push down from i=1Dis1=500;Oil1=500;DoK=k+1;D=d+500/ (2*k-1);Disk=d;Oilk=oilk-1+500;while (d=1000);Disk=1000; / * the start point to the end point of the distance.D1=1000-disk-1; / * for i=n to the starting point of the distance.Oilk=d1* (2*k+1) +oilk-1; / *

16、for starting point of oil reservoir.For (i=0; ik; i+) / * starting from the start point to the starting point to print the current oil storage point distance and the amount of oil reservoir.Printf (%dt%ft%ftn, I, 1000-disk-i, oilk-i);Practical algorithm (basic algorithm - recursive method -02)Date o

17、f issue: April 10, 2003 provenance: analysis and programming of practical algorithms. Author: C language home collation, 1317 readers have read this articleForward pushing methodThe reverse process of the push down method is pushed along, starting from the boundary conditions, the recursive relation

18、s launched by the latter value, value according to the recursive formula of re launch, followed by consequent value. recursive, until the problem from the initial statement to move forward to the solution of this problem.Real number sequence: a real number series with N items knownAi= (ai-1-ai+1) /2

19、+d, (1iN) (N60)The keyboard inputs are N, D, A1, an, m, and output amNo error is required for input data.Algorithm analysis:Analysis of the problem, the formula:Ai= (Ai-1-Ai+1) /2+d (1iN) (n=2) can be calculated:S32= (0,0,1) =S21;S33= (1,0,0) =S22;S34= (-2,2,1) =S23;S35= (5, -2-2) =S24;And.S3i= (.) =S2i-1;.

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1