CS FundamentalsVery hardGATE CS
For integer variables, what is the weakest precondition wp(x := x + 1; y := 2 * x, y > 10)?
- A. x > 5
- B. x > 4
- C. x > 9
- D. y > 10
Correct answer: B. x > 4
Work backwards: wp(y := 2x, y > 10) is 2x > 10, then substituting x + 1 for x gives 2(x + 1) > 10, i.e. x > 4. x > 5 forgets the increment, and y > 10 just repeats the postcondition, which mentions a variable the assignments overwrite.
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
- Which Hoare triple is valid for integer variables (partial correctness)?
- This loop sums an array: python i = 0; s = 0 while i < n: s = s + a[i] i = i + 1 Which assertion is a loop invariant (true every time the…
- Two identical servers run in parallel (the system works while at least one does). Each fails independently with an exponential failure…
- A team fits the Goel–Okumoto reliability-growth model μ(t) = a(1 − e^(−bt)) to its test data, with a = 120 expected total faults and b =…
- Why does the classic hardware 'bathtub' failure curve not fit software?
- A static analyser is described as SOUND for null-pointer dereferences. What does that guarantee?