York University EECS 3101 1. Loop Invariants: algorithm Sum(a,b) pre−cond: bisapositive integer. a can be any real. post−cond: a+b is returned begin x =a y =b r =2⌊log2y⌋ (the biggest power of 2 not bigger than y.) loop loop−invariant : ??? exit when y = 0 if( y ≥ r ) case 1 x =x+r y =y−r else case 2 r =r/2 end if end loop return(x ...[Show More]
Category: | |
Number of pages: | 3 |
Language: | English |
Last updated: | 2 months ago |
Downloads: | 1 |
Views: | 2 |