The difference between your answers and the book's is that you seem to be looking at whether the algorithm terminates after just one pass through the loop. In fact, you are asked whether the algorithmeventuallyterminates.

In Example a), if b=2 then k starts with the value 2. This is less than 5, so we pass through the loop and k emerges with the value 3. This is less than 5, so we have to pass through the loop again, and this time k emerges with the value 5. This fails the k<5 test, so at this stage the algorithm terminates.

On the other hand, if b=0 then as k goes through the loop it emerges with the value -1 (after the first pass), then -3 (after the second pass), then successively -7, -15, -31, ... . It's clear that after each pass k gets more and more negative, so it will never be greater than 5 and the algorithm will never terminate.

In Example c), suppose for example that b=0. Then the successive values of k as it passes through the loop are 0, 1, 3, 7, and at that point the algorithm terminates.

On the other hand, if k<0 then 2k+1<0, so if b is negative then k has a negative initial value, and will remain negative no matter how many times it passes through the loop. Therefore if b<0 then the program will not terminate.