最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

证明算法如何工作

SEO心得admin89浏览0评论
本文介绍了证明算法如何工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

给出伪代码

MUL(a,b) x=a y=0 WHILE x>=b DO x=x-b y=y+1 IF x=0 THEN RETURN(true) ELSE RETURN(false)

我必须证明算法的工作原理.

I have to prove how the algorithm works.

到目前为止,我只解释了它的工作原理,但是我不确定您应该如何证明它的工作原理.

So far I have only explained how it works, but I am not sure how you are supposed to prove how it works.

编辑:仅作说明.我确实在另一个线程上问过这个问题.但是,这两个问题是分开的.我正在处理的作业包含3个问题.第一个问题是我在哪里解释了算法的工作原理.第二个问题在我的另一个线程上,第三个问题(该线程)在哪里我必须证明我在问题1中解释的算法是如何工作的.我问这个问题的原因不是要得到问题的答案,而只是对我被要求做的事情的解释,因为我似乎无法自己弄清楚.就我个人而言,我只会做与第一个问题相同的事情,但这没有多大意义.

Just to clarify. I did ask this question on another thread. But the two questions are separate. The assignment I am working on consists of 3 questions. The 1st question is where I explained how the algorithm works. The 2nd question is on my other thread and the 3rd question (this thread) is where I have to prove how the algorithm I explained in question 1 works. The reason why I asked this question is not to get the answer to the question, but simply an explationation as to what I am asked to do since I can't seem to figure it out myself. Personally I would just do the same as the 1st question, but that wouldn't make much sense.

推荐答案

尝试显示算法的前置条件和后置条件.前置条件确定执行之前的初始状态,后置条件确定执行之后的最终状态.

Try to show the Pre-condition and Post-condition of the algorithm. Pre-condition predicates the initial state before execution and Post-condition predicates the final state after execution.

如果可以证明如果前置条件为真,则后置条件必须为真,该算法是正确的.

The algorithm is correct if it can be proved that if the pre-condition is true, the post-condition must be true.

查看更多信息:证明如何算法有效

发布评论

评论列表(0)

  1. 暂无评论