AQA D1 2007 January — Question 5

Exam BoardAQA
ModuleD1 (Decision Mathematics 1)
Year2007
SessionJanuary
TopicSorting Algorithms

5 A student is using the following algorithm with different values of \(A\) and \(B\).
Line 10Input \(A , B\)
Line 20Let \(C = 0\) and let \(D = 0\)
Line 30Let \(C = C + A\)
Line 40Let \(D = D + B\)
Line 50If \(C = D\) then go to Line 110
Line 60If \(C > D\) then go to Line 90
Line 70Let \(C = C + A\)
Line 80Go to Line 50
Line 90Let \(D = D + B\)
Line 100Go to Line 50
Line 110Print \(C\)
Line 120End
    1. Trace the algorithm in the case where \(A = 2\) and \(B = 3\).
    2. Trace the algorithm in the case where \(A = 6\) and \(B = 8\).
  1. State the purpose of the algorithm.
  2. Write down the final value of \(C\) in the case where \(A = 200\) and \(B = 300\).