摘要:
循环不变式就是在进行循环时,在每次循环都保持不变的逻辑表达式,相当于数学归纳法证明的“断言”。算法导论第二章中关于循环不变式原文如下:We state these properties ofA[1 ‥j-1] formally as aloop invariant。We use loop invariants to help us understand why an algorithm is correct. We must show three things about a loop invariant:Initialization:It is true prior to the first 阅读全文