1. Which construct chooses between two actions?
- Selection
- Storage
- Translation
Check the answer and reasoning
Selection
An IF condition selects a branch based on a Boolean result.
CS / Foundations
An algorithm is a finite, precise method for solving a defined problem. Sequence orders instructions, selection chooses branches and iteration repeats actions.
An algorithm is a finite, precise method for solving a defined problem. Sequence orders instructions, selection chooses branches and iteration repeats actions.
Trace an algorithm by recording variable values after each operation. Testing examples can reveal bugs, while a convincing correctness argument explains why all permitted inputs are handled.
Start x=2, then set x←x+3, then x←2x. What is x?
After addition x is 5; doubling gives 10.
Predict the worked result before calculating. Change one input, record the new result, and explain which assumptions still hold.
Use the prediction activity below; a local model appears only where it supports this topic.
Selection
An IF condition selects a branch based on a Boolean result.
10
After addition x is 5; doubling gives 10.
An infinite loop
A terminating loop needs progress toward a condition that ends repetition.