X sum of 110 put your answer here suppose this

This preview shows page 2 out of 2 pages.

x = sum of 1..10 Put your answer here Suppose this assertion is true: no value in h..k divides x Under what extra condition is this one true? no value in 2..n–1 divides x Put your answer here 11 Understanding assertions This is an assertion about v and k. It is true because chars of v[0..3] are greater than ‘C’ and chars of v[6..8] are ‘Z’s. 0 1 2 3 4 5 6 7 8 X Y Z X A C Z Z Z v This is a list of Characters v C ? all Z’s k 6 0 3 k 8 v C ? all Z’s k 5 0 3 k 8 v C all Z’s k 6 0 k 8 v W A C all Z’s k 4 0 k 8 Indicate whether each of these 3 assertions is true or false. 12 We add the postcondition and also show where the invariant must be true: initialization; // invariant: P while ( B ) { // { P and B} repetend // { P } } // { P } // { Result R } The four loopy questions Suppose we have this while loop, with initialization: initialization; while ( B ) { repetend } Second box helps us develop four loopy questions for developing or understanding a loop: 1. How does loop start? Initialization must truthify inv P. 2. When does loop stop? At end, P and !B are true, and these must imply R. Find !B that satisfies P && !B => R. 3. Make progress toward termination? Put something in repetend to ensure this. 4. How to keep invariant true? Put something in repetend to ensure this.
Image of page 2
You've reached the end of this preview.
  • Spring '07
  • DAVIDGRIES

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern