The subroutines Algorithm A and Algorithm B are designed to determine the number of half-lives required for an initial radioactive mass M M\,M to decay until it is less than or equal to a threshold mass TTT.
SUBROUTINE simulateDecay(M, T)
halfLives ← 0
WHILE M > T
M ← M / 2
halfLives ← halfLives + 1
ENDWHILE
OUTPUT halfLives
ENDSUBROUTINE
SUBROUTINE simulateDecay(M, T)
halfLives ← 0
REPEAT
M ← M / 2
halfLives ← halfLives + 1
UNTIL M ≤ T
OUTPUT halfLives
ENDSUBROUTINE
Describe two differences in the way the loops in Algorithm A and Algorithm B operate.
298 exam-style questions on AQA GCSE Computer Science Programming concepts. Each one has a worked solution and a mark scheme showing where the marks go.