Question 1
OCR A Further Maths November 2020 Discrete mathematics (Y534-01)AS10 marks
On the specification
- (a)
- 7.03 Algorithms
- (b)
- 7.03 Algorithms
- (c)
- 7.03 Algorithms
- (d)
- 7.03 Algorithms
- (e)
- 7.03 Algorithms
Question text
1 Algorithm X is given below: STEP 1: Let A = 0 STEP 2: Input the value of B [B must be a positive integer] STEP 3: C = INT(B ÷ 3) STEP 4: D = B + 3C STEP 5: Replace A with (D - A) STEP 6: Decrease B by 1 STEP 7: If B 2 0 go to STEP 3 STEP 8: Display the value of ABS(A) and STOP (a) Trace through algorithm X when the input is B = 5. Only record changes to the values of the variables, A, B, C and D, using a new column of the table in the Printed Answer Booklet each time one of these variables changes. [5] (b) Explain carefully how you know that algorithm X is finite for all positive integer values of B. [2] (c) Explain what it means to say that an algorithm is deterministic. [1] The run-time of algorithm X is k ◊ (number of times that STEP 6 is used), for some positive constant k. (d) Explain, with reference to your answer to part (b), why the order of algorithm X is O(n), where n is the input value of B. [1] For each input B, algorithm Y achieves the same output as algorithm X, but the run-time of algorithm Y is m ◊ (the number of digits in B), where m is a positive constant. (e) Show that algorithm Y is more efficient than algorithm X. [1]