CS FundamentalsHardGATE CS
A loop `while i < n: i = i + 1` (integers) has the invariant i ≤ n. To prove TOTAL correctness rather than only partial correctness, what else must be shown?
- A. That the invariant i ≤ n still holds at the moment the loop exits
- B. A variant like n − i, bounded below and falling every iteration
- C. That the postcondition implies the precondition of the whole loop
- D. That every statement in the loop body is executed at least once
Correct answer: B. A variant like n − i, bounded below and falling every iteration
Partial correctness says the result is right if the loop ends; termination needs a well-founded measure. n − i stays ≥ 0 while the guard holds and drops by 1 each pass, so the loop must stop.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- Match each UML sequence-diagram combined fragment with its meaning. P. alt Q. opt R. loop S. par 1. Runs only if its single guard is true…
- In a UML component diagram, PaymentService shows a small circle on a stick labelled IPayment, and Checkout shows a half-circle cup…
- A team uses Basic COCOMO for a 50 KLOC project. How many times larger is the embedded-mode effort (3.6 × KLOC^1.20) than the organic-mode…
- A work breakdown structure is said to follow the 100% rule. What does that mean?
- A game studio adds Git LFS for its .psd and .fbx files. Which statement is correct?
- A developer uses git worktree add ../hotfix main while her current directory has feature checked out. Which statement is correct?