Question 5

Edexcel Computer Science June 2025 Paper 1GCSE20 marks

On the specification

(a)
1.3 Truth tables
(b)(i)
6.2 Program constructs6.3 Data types and structures
(b)(ii)
6.1 Develop code
(c)
1.2 Algorithms6.5 Operators
(d)(i)
1.2 Algorithms
(d)(ii)
1.2 Algorithms
(e)
1.2 Algorithms
Question text

5 Computational thinking (a) Here is a partially completed truth table. The logical expression for Q is complete. Complete the truth table to give the: • logical expression for S • logical expression for T • values for Q (3) A B C S T Q NOT S AND T 0 0 0 0 0 1 0 1 1 0 0 1 1 1 0 1 10 0 0 0 10 1 1 1 11 0 0 1 11 1 1 1 (b) Here is an algorithm to process sales data. 1 # ––––––––––––––––––––––––––––––––––––––––––––––––– 2 # Global variables 3 # ––––––––––––––––––––––––––––––––––––––––––––––––– 4 5 salesData = [[9, 6, 32], 6 [20, 12, 9], 7 [9, 8, 8], 8 [32, 24, 29], 9 [7, 20, 12], 10 [6, 9, 6]] 11 total = 0 12 currMax = 0 13 14 # ––––––––––––––––––––––––––––––––––––––––––––––––– 15 # Main program 16 # ––––––––––––––––––––––––––––––––––––––––––––––––– 17 for sale in salesData: 18 total = 0 19 for item in sale: 20 total = total + item 21 if (item < currMax): 22 currMax = item 23 print (sale, total) 24 print (currMax) 25 (i) The data structure salesData is shown as a table of records, with fields in each record. Complete the table with the line number for each traversal. (2) Line number Traverses the records Traverses the fields (ii) There is a logic error in the code. Write the corrected line of code. (1) (c) Here is an algorithm. 1 # ––––––––––––––––––––––––––––––––––––––––––––––––– 2 # Constants 3 # ––––––––––––––––––––––––––––––––––––––––––––––––– 4 5 NUM = 6 6 7 # ––––––––––––––––––––––––––––––––––––––––––––––––– 8 # Global variables 9 # ––––––––––––––––––––––––––––––––––––––––––––––––– 10 11 total = 0 12 13 # ––––––––––––––––––––––––––––––––––––––––––––––––– 14 # Main program 15 # ––––––––––––––––––––––––––––––––––––––––––––––––– 16 17 for number in range (1, NUM + 1): 18 remainder = NUM % number 19 if (remainder == 0): 20 total = total + number 21 print (total) 22 Complete the trace table. You may not need to fill in all the rows in the table. (4) number remainder total Output 0 (d) The efficiency of algorithms can be analysed. The worst case is when the most comparisons are required. The best case is when the fewest comparisons are required. (i) Explain the worst case for a linear search on an array. (2) (ii) Explain the best case for a bubble sort on an array. (2) (e) A binary search algorithm looks for a target in a sorted array. Here is an array of numbers. Index [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] Value 11 22 33 44 55 66 77 88 99 100 101 Complete the table to show the steps of a binary search algorithm to look for the number 78, which is not in the array. You must show the calculation of the mid-point. You may not need to fill in all the rows in the table. (6) Start End Calculation of Found Discard lower, index index mid-point Y or N higher or none (Total for Question 5 = 20 marks)