Computer Science
Algorithms, programming and logic — Paper 2
- 1.
Write pseudocode that repeatedly inputs a test score until the value is between 0 and 100 inclusive, then outputs ‘valid’. Use a post-test or pre-test loop.
[4 marks] · no calculator - 2.
A program calculates delivery charges from parcel weight. Design four test cases covering normal, boundary, invalid and extreme data. State the input and purpose of each case.
[4 marks] · no calculator - 3.
Write pseudocode to find and output the largest value in an array of 10 integers called Scores.
[4 marks] · no calculator - 4.
The list [5, 2, 8, 1] is sorted into ascending order using a bubble sort. State the list after the first full pass.
[3 marks] · no calculator - 5.
A list of 1,000 names is already sorted alphabetically. Which search algorithm will generally find a specific name fastest? A Linear search B Binary search C Bubble sort D Insertion sort
[1 mark] · no calculator - 6.
Write pseudocode using nested IF statements that outputs a grade for a given Score: 'A' if the score is 90 or above, 'B' if it is 75 or above but below 90, and 'C' otherwise.
[3 marks] · no calculator - 7.
Explain one advantage of using a function (subroutine) rather than repeating the same code several times in a program.
[2 marks] · no calculator - 8.
A form asks a user to enter their age as a whole number between 1 and 120. Identify two different validation checks that could be applied, and explain what each one checks for.
[4 marks] · no calculator - 9.
A loop runs the pseudocode 'Count ← Count + 1' three times, starting with Count = 0. Complete a trace table showing the value of Count after each of the three iterations.
[3 marks] · no calculator - 10.
Write pseudocode to calculate and output the average of 5 numbers stored in an array called Marks.
[4 marks] · no calculator - 11.
Explain the difference between a variable and a constant in a program.
[2 marks] · no calculator - 12.
Explain why a 2D array would be a suitable data structure to store the seating plan of a cinema with rows and columns of seats.
[2 marks] · no calculator - 13.
Explain what the string length function would return when applied to the text 'Cambridge', and give one reason a programmer might need this value.
[2 marks] · no calculator - 14.
Distinguish between a count-controlled loop and a condition-controlled loop, using an example of when each would be appropriate.
[2 marks] · no calculator - 15.
The list [8, 3, 6, 1] is sorted into ascending order using an insertion sort. State the list after the algorithm has correctly inserted the second element (3) into its sorted position among the first two elements.
[2 marks] · no calculator - 16.
Write pseudocode for a linear search that looks for a Target value in an array called Items, and outputs whether the value was found.
[4 marks] · no calculator - 17.
Explain what a decision (diamond-shaped) symbol represents in a flowchart.
[2 marks] · no calculator - 18.
Write pseudocode to count how many values in an array called Scores are greater than 50.
[4 marks] · no calculator - 19.
Explain one advantage of writing a procedure that accepts parameters, rather than one that always works on fixed, built-in values.
[2 marks] · no calculator - 20.
A form requires a user to enter their name. Explain what a presence check would do, and why it is needed for this field.
[2 marks] · no calculator - 21.
A system requires a new password to be at least 8 characters long. Explain what a length check would do when this password is entered.
[2 marks] · no calculator - 22.
Explain, in simple terms, what it means for a function to be recursive, using a function that calculates factorials as an example.
[2 marks] · no calculator - 23.
Explain one feature of an Integrated Development Environment (IDE) that helps a programmer write code with fewer errors.
[2 marks] · no calculator - 24.
Explain the purpose of using meaningful variable names, such as 'studentAge' instead of 'x', when writing a program.
[2 marks] · no calculator