Question 4(b) 2023 · October-November · Paper 21 · 11 marks
Reveal official mark-scheme answer
Official answer for Question 4
Part (b)
Question 3
- Single IF statement using AND, or
- Two nested IFs using AND, or
- Single IF and the use of a two-iteration loop
Show text version of question
Question 4
Part (b)
Question 4
TopOfStack
3 BottomOfStack
Question 2
Question 1
Question 5
Part (b)
A function Push() will add a value onto the stack by manipulating the array and variables in
part (a).
Before adding a value onto the stack, the algorithm will check that space is available.
If the value is added to the stack, the function will return TRUE, otherwise it will return FALSE.
The algorithm is expressed in five steps.
Complete the steps.
1. If ........................................................ then return FALSE
2. Otherwise .......................................... TopOfStack
3. Use TopOfStack as an ................................... to the array.
4. Set the element at this ...................................... to the .............................. being added.
5. Return .............................. .
Question 6
4 A global array is declared in pseudocode as follows:
DECLARE Data : ARRAY[1:150] OF STRING
1. take two parameters:
- a string (the search string)
- an integer (the maximum value)
2. count the number of strings in the array that exactly match the search string 3. return TRUE if the count is greater than the maximum value, otherwise will return FALSE
Part (b)
The global array is changed to a 2D array, organised as 150 rows by 2 columns. It is declared
in pseudocode as follows:
DECLARE Data : ARRAY[1:150, 1:2] OF STRING
The algorithm for the function in part
Part (a)
is changed. Strings will only be counted if both of
the following conditions are true:
- The current row is an even number.
- The search string exactly matches the value in either column.
Write pseudocode to check these conditions.
Assume that the row index is contained in variable Row and the search string in variable Search.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................
Question 8
Why this question appears here
99% assigned-topic match · Programming › Constructs
Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.
Permanent source page: Educate A Change · From 9618_w23_qp_21.pdf
