This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Sheet1 Page 1 Winter 2008 Answer key 1)D 2) B 3)D 4) D 5) D hmmm...it's always D apparently 6)E (correct output is 1 1 2 5 6 7 7 ) 7)A 8)C 9)B 10) D 11)A is no good because the second do loop if (as in the example) n=6, d=2, then we have k=1 to 4.....then we say vec(62+k For b, again, suppose d=2, n=6. then k goes from 1 to 6. Suppose k is 5. Then mod(5,6) = 5 . 5 + d = 7. ....but vec1(7) doesn' C is correct One way to think about D is the following: K ranges from d+1 until n+d. If we assume n=6 and d=2 again, then we have K rang vec2(n+dk+1) then ranges from ( n+d  3 + 1) = (6) until (n+d8+1) = 1 so the left side ranges from vec2(6) until vec2(1) The right side ranges from 3d = 1 until 8d= 6 So the right side ranges from vec1(1) until vec1(6). This essentially means we So C is the only answer that works 12) C will also work for any nonnegative integer since the only time d is used is in taking the mod 13) A, B, C 14) note: fall 2008 midterm will only have multiple choice so a question like this would not be asked...
View
Full
Document
This note was uploaded on 01/15/2010 for the course COMP COMP 206 taught by Professor Vybihal during the Spring '04 term at McGill.
 Spring '04
 Vybihal

Click to edit the document details