AQA D1 2011 January — Question 8

Exam BoardAQA
ModuleD1 (Decision Mathematics 1)
Year2011
SessionJanuary
TopicFixed Point Iteration

8 A student is tracing the following algorithm with positive integer values of \(A\) and \(B\).
The function INT gives the integer part of a number, eg INT(2.3) \(= 2\) and \(\operatorname { INT } ( 3.8 ) = 3\).
Line 10Let \(X = 0\)
Line 20Input \(A , B\)
Line 30If \(\operatorname { INT } ( A / 2 ) = A / 2\) then go to Line 50
Line 40Let \(X = X + B\)
Line 50If \(A = 1\) then go to Line 90
Line 60Let \(A = \operatorname { INT } ( A / 2 )\)
Line 70Let \(B = 2 \times B\)
Line 80Go to Line 30
Line 90Print \(X\)
Line 100End
  1. Trace the algorithm in the case where the input values are \(A = 20\) and \(B = 8\).
  2. State the purpose of the algorithm.
  3. Another student changed Line 50 to Line 50 If \(A = 1\) then go to Line 80
    Explain what would happen if this algorithm were traced.
    \includegraphics[max width=\textwidth, alt={}]{d1e453d6-0abb-4a7e-87c1-28275074dd08-17_2486_1714_221_153}