- 1、本文档共47页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
* * * * * * * * * * * * * * * * * * * * * * * * Trace Table Example: Cycle T Cycle T: L = 1, N = 2, T = T ClearSpaces(var Input: string; State: int) # 1 2 3 4 5 6 Instructions Condition Input Length State Length := length(Input)State := 0 repeat if Input[Length-1] = ‘ ‘ Length := Length - 1 false if State 2 State:=State+1 else State := 3 until State=3 or Length=0 true 3 ‘ AB…’ 3 2 7 Verifying Program Correctness Correctness verification methods treat programs as mathematical theorems. These methods are particularly useful during design and design review. Because program verification often involves sophisticated reasoning, it is important to check your work carefully. Correctness Verification To verify a program identify all of the program cases consider each verification question while reviewing each non-trivial construct where the answer is not obvious, use a trace table to evaluate the conditions that the program must satisfy While this verification approach works with most design constructs, only “while loops” are described in this lecture. Proofs for repeat-until and for-loops are described in the textbook (pages 301 – 308). WhileLoop Verification -1 The WhileLoop is assumed to have the following form. WhileLoop Verification -2 A while-loop is correct if all of the following questions can be answered with “yes.” Question 1: Is loop termination guaranteed for any argument of WhileTest? Question 2: When WhileTest is true, does WhileLoop = LoopPart followed by WhileLoop? Question 3: When WhileTest is false, does WhileLoop = identity? WhileLoop Example -1 Assuming n 0, calculate n! WhileLoop Example -2 Question 1: Is loop termination guaranteed for any argument of WhileTest? Yes, the loop terminates when i = n. Since i steps inside the loop, it will terminate as long as n 0. Question 2: When WhileTest is true, is WhileLoop = LoopPart followed by WhileLoop? Yes, the LoopPart increments i and sets f equal to f * i, so
您可能关注的文档
- 唐诗欣赏quan.ppt
- 情境一酒水服务 项目三啤酒鱼黄酒服务.ppt
- 压力容器常识(特种设备培训).ppt
- 第三章_VHDL基础10.10-5.0.ppt
- 江苏联通大学生市场营销策略研究建议书.ppt
- 新企业所得税疑点难点解析(2010).ppt
- 药学导论(中药).ppt
- 孕产期营养与健康-杨 (T).ppt
- 岸芷汀兰个案赏析.ppt
- 第8章: 综合决策支持系统(2).ppt
- 2024自考专业(公共关系)试题预测试卷含答案详解【预热题】.docx
- 2024自考专业(公共关系)试题预测试卷【名师推荐】附答案详解.docx
- 2024自考专业(公共关系)试题附答案详解【轻巧夺冠】.docx
- 2024自考专业(公共关系)试题预测试卷【有一套】附答案详解.docx
- 2024自考专业(公共关系)试题预测试卷及完整答案详解(考点梳理).docx
- 2024自考专业(公共关系)试题预测试卷及完整答案详解.docx
- 2024自考专业(公共关系)试题预测试卷【新题速递】附答案详解.docx
- 2024自考专业(公共关系)试题含答案详解(实用).docx
- 2024自考专业(公共关系)试题及完整答案详解【网校专用】.docx
- 2024自考专业(公共关系)试题含答案详解(新).docx
最近下载
- DB37∕T 242-2021 建筑消防设施检测技术规程.docx
- PE管材验收标准(SDR17.6).docx VIP
- 复旦大学《计算机体系结构》期末考试两套试卷(含答案).pdf VIP
- 中国近现代史纲要知到课后答案智慧树章节测试答案2025年春海南大学.docx VIP
- 形考作业3:基于UML的大学图书馆图书信息管理系统设计实验.docx VIP
- 大学《地震工程学》课程课件.pptx
- 2024年二建继续教育-基于建筑信息模型、虚拟施工及网络的项目管理理论及实践1、2答案.docx VIP
- 2024年二建继续教育-剖析价值工程及如何运用价值工程优选设计方案1、2答案.docx VIP
- 茶颜悦色案例分析.pptx VIP
- yolov9论文中文翻译.docx VIP
文档评论(0)