星期日, 1月 28, 2007

I2A 2.1

整個2.1說明了兩個重點,iteration和Pseudocode Conventions,後者好理解,前者述說了for loop的三個關鍵性重點。


Initialization: It is true prior to the first iteration of the loop.
Maintenance: If it is true before an iteration of the loop, it remains true before the next iteration
Termination: When the loop terminates, the invariant gives us a useful property that helps show that the algorithm is correct


其中,在上學期,老師講的很廢話的loop invariant在這一章節也有很好的解釋,在I2A p.17寫到

At the start of each iteration of the for loop of lines 1-8, the subarray a[1... j-1] consists of the elements originally in A[1... j-1] but in sorted order.


跟另外一本書比起來....實在是好懂的多,而2-2大略已讀畢,2-3尚未開始,但是Designing Algorithms 這個標題,雖然知道不太可能以一節寫畢,但是所能提供的概觀讓人期待

---
無線網路能用了,寫作會輕鬆很多。

沒有留言: