AQA D1 2011 January — Question 8 7 marks

Exam BoardAQA
ModuleD1 (Decision Mathematics 1)
Year2011
SessionJanuary
Marks7
PaperDownload PDF ↗
Mark schemeDownload PDF ↗
TopicSorting Algorithms
TypeAlgorithm Tracing
DifficultyEasy -1.2 This is a straightforward algorithm tracing exercise requiring systematic step-by-step execution and pattern recognition. Part (a) is mechanical bookkeeping, part (b) requires recognizing the algorithm computes A×B (multiplication via repeated doubling), and part (c) tests understanding of infinite loops. No complex problem-solving or mathematical insight needed beyond careful trace execution.
Spec7.03a Algorithm definition: input, output, deterministic, finite7.03c Working with algorithms: trace, interpret, adapt

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 INT(3.8) = 3. Line 10: Let \(X = 0\) Line 20: Input \(A\), \(B\) Line 30: If INT\((A/2) = A/2\) then go to Line 50 Line 40: Let \(X = X + B\) Line 50: If \(A = 1\) then go to Line 90 Line 60: Let \(A =\) INT\((A/2)\) Line 70: Let \(B = 2 \times B\) Line 80: Go to Line 30 Line 90: Print \(X\) Line 100: End
  1. Trace the algorithm in the case where the input values are \(A = 20\) and \(B = 8\). [4]
  2. State the purpose of the algorithm. [1]
  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. [2]

Question 8:
8
Question 8:
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 INT(3.8) = 3.

Line 10: Let $X = 0$
Line 20: Input $A$, $B$
Line 30: If INT$(A/2) = A/2$ then go to Line 50
Line 40: Let $X = X + B$
Line 50: If $A = 1$ then go to Line 90
Line 60: Let $A =$ INT$(A/2)$
Line 70: Let $B = 2 \times B$
Line 80: Go to Line 30
Line 90: Print $X$
Line 100: End

\begin{enumerate}[label=(\alph*)]
\item Trace the algorithm in the case where the input values are $A = 20$ and $B = 8$. [4]
\item State the purpose of the algorithm. [1]
\item 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. [2]
\end{enumerate}

\hfill \mbox{\textit{AQA D1 2011 Q8 [7]}}