CS FundamentalsVery hardGATE CS
For integer x, what is the weakest precondition wp(if x > 0 then y := x else y := −x, y ≥ 2)?
- A. x ≥ 2
- B. x ≥ 2 or x ≤ −2
- C. x > 0 and x ≥ 2
- D. true
Correct answer: B. x ≥ 2 or x ≤ −2
wp(if B then S1 else S2, Q) = (B ∧ wp(S1, Q)) ∨ (¬B ∧ wp(S2, Q)) = (x > 0 ∧ x ≥ 2) ∨ (x ≤ 0 ∧ −x ≥ 2), i.e. x ≥ 2 or x ≤ −2 (|x| ≥ 2). Keeping only the then-branch gives x ≥ 2.
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
- An IDE has a small core that loads, at start-up, independently developed extensions which register through defined extension points. Which…
- An order flow touches payment, inventory and shipping services. In design 1 each service reacts to events from the others; in design 2 one…
- A producer emits 10,000 events per second into a stream whose consumer can process 2,000 per second. Which reactive-streams mechanism lets…
- A table of user events is sharded by event date, and all writes for today land on one shard, which is overloaded while others sit idle…
- Match each cost-of-quality category with an example. P. Prevention Q. Appraisal R. Internal failure S. External failure 1. Reworking a…
- An inspection of 500 delivered forms finds 25 defects, and each form has 10 opportunities for a defect. What is the…