Algorithm design and problem-solving – A Level Computer Science (old syllabus, to 2021) (9608)

10 questions

0 / 0Answer a question to start your score.
New quizSaved 0

Quick quiz: 10 random questions from this topic. Answer them all, then open the Summary.

Advertisement
1
9608/23/M/J/20 · Question 1May/June 2020Paper 238 marks
Loading question…
Question text

1
(a) Algorithms are produced during program development.
State when you would produce an algorithm during program development and state its
purpose.
When …
…
Purpose …
…
[2]
(b) Selection is one of the basic constructs used in algorithms.
Explain the term selection.
…
…
…
… [2]
(c) Explain the process of problem decomposition. State one reason it may be used.
Explanation …
…
…
Reason …
…
…
[2]
(d) Name two features provided by a typical Integrated Development Environment (IDE) that
assist in the debugging stage of the program development cycle.
1 …
2 …
[2]

2
9608/23/M/J/16 · Question 2May/June 2016Paper 2311 marks
Loading question…
Question text

2
The engine management system of a car includes an energy-saving facility. When certain
conditions are met, this facility will automatically stop the engine.
The system is to be software-based. It will include a subroutine, EnergySaver, which repeatedly
takes data from sensors in the car. The subroutine decides whether or not to set the EngineStop
value.
The table of identifiers used by this subroutine is shown below.
(a) Complete the identifier table below by stating the data types.
Identifier
Data type
Description
Accelerator pedal position
Values: 0 to 100 in steps of 1
Accelerator
…
Meaning:
0: none (not pressed)
100: maximum (fully pressed)
Engine temperature in °C
EngineTemp
…
(-50 to +150 stored to 1 decimal place)
Normal engine temperature in °C
NormalTemp
…
Whole number; typical value 90
Road speed of car (in km/hr)
Speed
…
Values: 0 to 200 in steps of 1
Value used to signal engine must be stopped
Possible values:
EngineStop
…
TRUE: stop engine
FALSE: run engine
[5]
The condition for stopping the engine is that all three of the following are true:
•
Accelerator is not pressed
•
Engine temperature is normal or above
•
Car speed is zero
The initial design stage will produce a prototype of EnergySaver, with a user interface.
The structured English for this is:
1.
INPUT value for accelerator pedal position
2.
INPUT value for engine temperature
3.
INPUT value for normal engine temperature
4.
INPUT value for car speed
5.
EVALUATE engine stopping condition
6.
IF stopping condition satisfied SET engine stop value to TRUE
7.
IF stopping condition not satisfied SET engine stop value to FALSE
8.
OUTPUT message indicating engine stop value
(b) Write the pseudocode equivalent of the structured English. Use the identifiers from the table
in part (a).
For the built-in functions list, refer to the Appendix on the last page.
…
…
…
…
…
…
…
…
…
…
…
…
…
…

3
9608/23/M/J/18 · Question 4May/June 2018Paper 2310 marks
Loading question…
Question text

4
A program controls a chemical process in a factory.
The temperature is monitored as part of the control process. The temperature is measured at
fixed time intervals and the value is stored in an array, PTemp. The array contains 100 elements,
representing 100 temperature values. The first element is PTemp[1].
The program will check whether the temperature is outside the acceptable range more than 20
times. This task is performed by a function, IsTempOK().
The algorithm for the function IsTempOK() is expressed in structured English as follows:
1
Examine each array element and count the number of times that a temperature is less than
MinTemp or more than MaxTemp.
2
If the count in step 1 exceeds 20, return FALSE, otherwise return TRUE.
Draw a program flowchart, on the next page, to represent the algorithm for the function
IsTempOK().
Assume:
•
the array contains 100 valid temperature values
•
PTemp, MinTemp and MaxTemp are global variables.
Note that variable declarations are not required in program flowcharts.
[9]

Advertisement
4
9608/21/M/J/17 · Question 1May/June 2017Paper 2116 marks
Loading question…
Question text

1
(a) Simple algorithms usually consist of three different stages.
Complete the following table.
Add a description of the stage and an example pseudocode statement.
The first stage has been given.
Stage
Description and example
Description: …
…
Input
Pseudocode example: …
…
Description: …
…
…
Pseudocode example: …
…
Description: …
…
…
Pseudocode example: …
…
[7]
(b) (i)
AND and OR are two operators that may be used when implementing an algorithm.
An example of their use is given in the following pseudocode statement:
VarA OR VarB
MyFlag
State the data type of variable MyFlag.
… [1]
(ii)
State the name given to the type of operators to which AND and OR belong.
… [1]
(iii)
Evaluate the expressions given in the following table when the variable values are as
follows:
TRUE
FlagA
FALSE
FlagB
TRUE
FlagC
Expression
Evaluates to
FlagA AND (FlagB OR FlagC)
FlagA AND (FlagB AND FlagC)
(NOT FlagA) OR (NOT FlagC)
[3]
(c) A common construct found in many algorithms is a loop.
Using pseudocode, write a pre-condition loop to output all of the even numbers between 99
and 201.
…
…
…
…
…
…
…
…
… [4]

5
9608/21/O/N/17 · Question 2Oct/Nov 2017Paper 2116 marks
Loading question…
Question text

2
The following pseudocode represents a simple algorithm.
DECLARE NumberFound, Remainder, Number : INTEGER
DECLARE StartNumber, EndNumber, Divisor : INTEGER
INPUT StartNumber
INPUT EndNumber
INPUT Divisor
0
NumberFound
StartNumber TO EndNumber
FOR Number
MODULUS(Number, Divisor)
Remainder
IF Remainder = 0
THEN
OUTPUT Number
NumberFound + 1
NumberFound
ENDIF
ENDFOR
OUTPUT "Count: " & NumberFound
For the built-in functions list, refer to the Appendix on page 14.
(a) Complete the following trace table.
StartNumber
EndNumber
Divisor
NumberFound
Number
Remainder
Output
11
13
2
0
[3]
(b) Describe the purpose of this algorithm.
…
…
…
…
…
… [3]
(c) Draw a program flowchart to represent this algorithm.
Variable declarations are not required in program flowcharts.
[10]

6
9608/22/M/J/20 · Question 1May/June 2020Paper 2210 marks
Loading question…
Question text

1
(a) Selection and repetition are basic constructs of an algorithm.
Name and describe one other construct.
Name …
Description …
…
…
[3]
(b) Program coding is a transferable skill.
Explain the term transferable skill.
…
…
…
… [2]
(c) Count-controlled and post-condition are two types of loop.
Describe the characteristics of each of these types of loop.
Count-controlled …
…
…
Post-condition …
…
…
[2]
(d) Name three features provided by an Integrated Development Environment (IDE) that assist
in the coding and initial error detection stages of the program development cycle.
1 …
2 …
3 …
[3]

7
9608/22/M/J/17 · Question 2May/June 2017Paper 2215 marks
Loading question…
Question text

2
A multi-user computer system maintains a text file containing the ID and preferred name for each
user.
User IDs are unique. Preferred names may be repeated.
(a) Stepwise refinement is to be applied to the following three steps.
After a user logs in, a welcome message is produced as follows:
1. Search for the user ID in the file.
2. Read the preferred name from the file.
3. Output the welcome message.
Describe the goal of stepwise refinement.
…
…
…
… [2]
(b) An initial identifier table is created as part of the stepwise refinement. A section of the table is
shown. Complete this table.
Identifier
Data type
Description
Stores the user ID entered
SearchUserID
…
FileUserID
…
…
FilePreferredName
…
…
IDFoundFlag
…
[5]
(c) The file may not contain an entry for every user. If the user ID is not found, then the name
“Guest” should be used as the preferred name.
Use structured English to write a more detailed algorithm for the welcome message process
described in part (a).
Use the identifiers given in the previous table.
Assume that the file, UserNames.txt, is organised as a simple text file. The user ID and
preferred name are held together in unencrypted form, one entry per line.
…
…
…
…
…
…
…
…
…
…
…
…

8
9608/21/O/N/16 · Question 1Oct/Nov 2016Paper 2114 marks
Loading question…
Question text

1
A programmer wants to write a program to calculate the baggage charge for a passenger’s airline
flight.
Two types of ticket are available for a flight:
•
economy class (coded E)
•
standard class (coded S)
Each ticket type has a baggage weight allowance as shown below. The airline makes a charge if
the weight exceeds the allowance.
Ticket type
Baggage allowance
Charge rate per additional kg
(kg)
($)
'E'
16
3.50
'S'
20
5.75
(a) A program flowchart will document the program. The flowchart will contain the following
statements:
Statement
Statement
number
0
Charge
1
INPUT BaggageWeight
2
ExcessWeight * ChargeRate
Charge
3
Is ExcessWeight > 0 ?
4
INPUT TicketType
5
BaggageWeight - BaggageAllowance
ExcessWeight
6
BaggageAllowance
16
7
3.5
ChargeRate
8
OUTPUT Charge
9
5.75
ChargeRate
10
BaggageAllowance
20
11
Is TicketType = 'E' ?
12
Complete the flowchart by putting the appropriate statement number in each flowchart
symbol. Statement 5 has been done for you.
Start
5
Stop
[6]
(b) The programmer needs data to test the flowchart.
Complete the table of test data below to show five tests.
TicketType
BaggageWeight
Explanation
Expected output
…
E
15
…
…
…
…
…
…
…
…
…
…
…
…
…
…
[5]
(c) The program design is to be amended. The value input by the user for the ticket type is to be
validated. Part of the amended flowchart is shown below.
Start
Loop
INPUT TicketType
Is
TicketType
E or S ?
No
Yes
Write pseudocode to use a pre-condition loop for this validation.
…
…
…
…
…
… [3]

Advertisement
9
9608/22/O/N/20 · Question 2Oct/Nov 2020Paper 2214 marks
Loading question…
Question text

2
(a) The following pseudocode is an attempt to define an algorithm that takes two numbers as
input and outputs the larger of the two numbers.
DECLARE A, B : INTEGER
INPUT A
INPUT B
IF A > B
THEN
OUTPUT A
ELSE
OUTPUT B
ENDIF
The algorithm needs to be amended to include the following changes:
Input three values, ensuring that each value input is unique.
1.
2.
Output the average.
3.
Output the largest value.
Write the pseudocode for the amended algorithm.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…

10
9608/21/M/J/20 · Question 1May/June 2020Paper 218 marks
Loading question…
Question text

1
(a) Complete this definition of the term algorithm.
An algorithm is a solution to a problem expressed as …
…
… [2]
(b) A program design includes the use of subroutines (functions and procedures).
Give three advantages of using subroutines in a program.
1 …
…
2 …
…
3 …
…
[3]
(c) Draw lines on the following diagram to connect each computing term with the appropriate
description.
Term
Description
Checking that a program
Selection
performs as expected
A method for increasing the
Black-box testing
level of detail of an algorithm
To test a condition to determine
Stepwise refinement
the path of program execution
A method of executing certain
Iteration
lines of code more than once
[3]

Advertisement