Filters
Year Range
20212025
2021
2022
2024
2025
Difficulty
Session
Variant
Sub-topic
100 questions
Computer Science/Paper 2/Algorithm Design and Problem-solving
CAIEAS Level9618-as · Paper 2

Algorithm Design and Problem-solving

100 questions· page 1 of 10

Q12025 May/Jun·P213 partsMedium-Easy
(a)

An identifier table has been used during the design stage.

Complete the identifier table:

Example valueExplanationVariable nameData type
"Fruit"a category of stock that is sold in the shop
20/02/2025when an item was sold
12.67the cost of an item
TRUEto indicate if an item is in stock
(b)

A module Sales() is part of the stock control program.

The table contains pseudocode extracts from the module Sales()

Each extract may include all or part of:

  • assignment
  • selection
  • iteration (repetition).

Complete the table by placing one or more ticks (✓) in each row:

Pseudocode extractAssignmentSelectionIteration
Result ← CalculateTotal()
WHILE IsClosed
REPEAT
INPUT Value
UNTIL Sales[4] > Value
IF Sales[Current] <= 150 THEN
Discount ← TRUE
ENDIF
CASE OF Option
(c)

Decomposition has been used to design the program to help the shop manager control the stock.

Describe decomposition.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................

Similar questions
Q32025 May/Jun·P218MMedium

A student has been asked to create a simple guessing game program. This program will generate a random integer value between 1 and 100. It will then repeatedly prompt the user to input an integer value until they input the randomly generated value.

The student has written a structured English description:

step 1 – randomly generate an integer value between 1 and 100 inclusive
step 2 – prompt the user to input an integer value
step 3 – output an appropriate message if the value input was too high; then repeat from step 2
step 4 – output an appropriate message if the value input was too low; then repeat from step 2
step 5 – output an appropriate message if the value input was the same value that was randomly generated; then end the program.

Write a pseudocode algorithm from this structured English description.

Assume no input validation is needed.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

....................................................................................................................................................

Similar questions
Q32025 May/Jun·P228MMedium

An algorithm is designed to generate and output two unique random integers. Each integer value is between –10 and 10 inclusive.

If both integers output are negative, a third random integer between 30 and 35 inclusive will be generated and output.

Write pseudocode for this algorithm.

Similar questions
Q42025 May/Jun·P226MMedium

An algorithm will:

• input 100 integer values, one value at a time
• store the first value input into the first location of the array Number
• store the next input value in the next unused location of the array Number
• output the contents of Number array in the opposite sequence to that in which the values were input.

Complete the program flowchart to represent the algorithm.

Variable declarations are not required.

Similar questions
Q32025 May/Jun·P237MMedium

A programmer has been asked to create a module RollDice() to simulate multiple rolls of a dice. This module will be used as part of a program for a game.

The module will:

step 1 – take a positive integer parameter representing the number of times the dice will be rolled

step 2 – simulate one roll of the dice by generating a random integer between 1 and 6 inclusive

step 3 – output the integer generated

step 4 – repeat, as required from step 2

step 5 – calculate the average value of the random integers generated

step 6 – return the average value.

Write pseudocode for the module RollDice()

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

....................................................................................................................................................

Similar questions
Q22025 Oct/Nov·P215MMedium

Data is a global 1D array containing 30 elements of type STRING

An algorithm will output:

  • all non-blank elements (elements that do not contain an empty string)
  • the final total of the number of elements output.

Complete the program flowchart to represent the algorithm:

Similar questions
Q22025 Oct/Nov·P225MMedium

Data is a global 1D array containing 20 elements of type REAL

An algorithm will:

  • input a sequence of real values, one at a time
  • assign each value to consecutive array elements, starting from index 1
  • end when the value 99.9 is input, or all 20 elements have been assigned (the value 99.9 must not be stored in the array).

Complete the program flowchart to represent the algorithm:

Similar questions
Q62025 Oct/Nov·P227MMedium

A string function Compare() will compare two strings.

The function will:

  • take four parameters:
    • two strings, String1 and String2
    • a character, Position, to indicate whether String1 will be compared with the start ('s'), or the end ('e') of String2
    • a Boolean, CaseMatters, to indicate whether an upper case character and lower case character (for example, 'A' and 'a') are regarded as different (TRUE), or as the same (FALSE)
  • return FALSE if String2 has fewer characters than String1
  • return TRUE if the comparison is true, otherwise return FALSE

For example:

ParameterReturn value
String1String2CaseMattersPosition
"Cat""Catalogue"TRUE's'TRUE
"CAT""Catalogue"TRUE's'FALSE
"CAT""Catalogue"FALSE's'TRUE
"Cat""Catalogue"TRUE'e'FALSE
"GUE""Catalogue"FALSE'e'TRUE
"Catalogue""Cat"TRUE's'FALSE

Write pseudocode for the function Compare()

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

....................................................................................................................................................

Similar questions
Q22025 Oct/Nov·P232 partsMedium-Easy
(a)

Describe up to six steps for this algorithm that could be used to produce pseudocode.

Do not use pseudocode statements in your answer.

Step 1 .......................................................................................................................................

Step 2 .......................................................................................................................................

Step 3 .......................................................................................................................................

Step 4 .......................................................................................................................................

Step 5 .......................................................................................................................................

Step 6 .......................................................................................................................................

(b)

Iteration is one programming construct.

Identify one other programming construct that will be required when the algorithm from part (a) is converted into pseudocode and explain how it is used.

Construct ..................................................................................................................................

Use ...........................................................................................................................................

Similar questions
Q22024 May/Jun·P222 partsMedium
(a)

An algorithm for part of the program will:

  • input three numeric values and assign them to identifiers Num1, Num2 and Num3
  • assign the largest value to variable Ans
  • output a message giving the largest value and the average of the three numeric values.

Assume the values are all different and are input in no particular order.

Complete the program flowchart on page 5 to represent the algorithm.

(b)

A different part of the program contains an algorithm represented by the following program flowchart:

Write pseudocode for the algorithm.

Similar questions