Question 3
OCR Computer Science June 2024 Computational thinking, algorithms and programming (J277-02)GCSE11 marks
On the specification
- (a)
- 2.3 Producing robust programs
- (b)
- 2.3 Producing robust programs
- (c)(i)
- 2.1 Algorithms
- (c)(ii)
- 2.1 Algorithms
- (c)(iii)
- 2.1 Algorithms
Question text
(a) State what is meant by the term syntax error. Give one example of a syntax error in a program. Definition Example [2] (b) A student writes an algorithm to input two numbers and add them together to create a total. If the total is between 10 and 20 inclusive, "success" is output. If the total is not between 10 and 20 inclusive, "warning" is output. 1 num1 = input("Enter a number") 2 num2 = input("Enter a number") 3 total = num1 + num1 4 if total >= 10 then 5 print("success") 6 else 7 print("warning") 8 endif The algorithm does not work correctly. Identify the line number of the two logic errors in the algorithm and refine the code to correct each logic error. Line number Correction Line number Correction [4] (c) (i) Show how a binary search will be used to find the number 10 in the following data set: 12 5 6 7 10 20 [3] (ii) State one pre-requisite for a binary search algorithm. [1] (iii) Tick (✓) one box to identify the name of the sorting algorithm that splits data into individual items before recombining in order. Bubble sort Insertion sort Merge sort [1]