To call a loop correct, what must be true?
Which three checks make a statement a loop invariant?
You tested your loop on fifty inputs and all passed. Why is it still not proven right?
A loop runs like this: start with x = 5. While x is not 0, print x, then subtract 1 from x. To call this loop correct, what must be true?
A loop starts with x at 5, prints x, subtracts 1, and repeats while x is not 0. What happens?
The loop that halves its number while it is even ends for every possible starting value.
Circle one: True False
A friend claims this loop always ends: while n is even, replace n with n divided by 2. Which starting value makes the loop run forever?
A loop adds up a list of any length. Which statement works as its invariant?
A friend claims the total always equals the full sum as the invariant of a summing loop. Which observation breaks this claim?
An insertion sort loop ends after handling every card. Its invariant says the handled cards sit in order. What follows?