Algorithm design and problem-solving – A Level Computer Science (old syllabus, to 2021) (9608)
10 questions · Clear filters
Question text
3
(a) Describe the term decomposition when used to develop algorithms.
…
…
…
…
…
… [3]
(b) Explain the term transferable skills and state how these skills are used in program
development.
…
…
…
… [2]
Question text
1
(a) Algorithms usually consist of three different stages.
One stage is INPUT.
Name the other stages.
1 …
2 …
[1]
(b) An algorithm may be documented using different methods. These include structured English,
a program flowchart, and pseudocode.
State what a program designer represents using one or more of these methods.
…
… [2]
(c) Programming languages support different data types.
Complete the table by giving four different data types together with an example data value
for each.
Data type
Example data value
[4]
(d) Draw lines to connect each of the following computing terms with the appropriate description.
Term
Description
A structure for the
Black-box testing
temporary storage of data
A method used when the
File
structure of the program is
unknown
A method of setting the
Assignment
value of a variable
A structure for the
Array
permanent storage of data
[3]
(e) A pseudocode algorithm assigns values to three variables as follows:
TRUE
FlagA
FALSE
FlagB
TRUE
FlagC
Evaluate the expressions given in the following table:
Expression
Evaluates to
NOT FlagB AND FlagC
NOT (FlagB OR FlagC)
(FlagA AND FlagB) OR FlagC
NOT (FlagA AND FlagB) OR NOT FlagC
[2]
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.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
Question text
2
(a) An algorithm is needed to input a list of numbers representing test marks for a class of
30 students.
The algorithm will output the number of students who have a mark greater than 75. It will also
output the average mark for the class.
Document the algorithm using structured English.
…
…
…
…
…
…
…
…
…
…
…
… [8]
(b) Each pseudocode statement in the following table contains an error.
State the error in each case.
Refer to the Appendix on page 16 for the list of built-in functions and operators.
Statement
Error
Code
LEFT(3, "Europe")
MID("ALARM:12:02", 7, 6)
Hour
LENGTH(27.5)
Size
INT(27 / (Count + 3)
Num
"Conditional" AND "Loop"
Result
[5]
(c) Part of a program flowchart is shown.
Set Index to 0
Set Status to FALSE
LOOP
Is
YES
Status = TRUE
?
NO
NO
Is Index > 100
?
Set Status to TopUp()
YES
SetLevel("Super")
Set Index to Index + 1
Write program code to implement the flowchart shown. Variable declarations are not
required.
Programming language …
Program code
…
…
…
…
…
…
…
…
Question text
1
(a) (i)
Programming languages can support different data types.
Complete the table by naming three different data types together with an example data
value for each.
Data type
Example data value
[6]
(ii)
Identify the type of programming statement that assigns a data type to a variable.
… [1]
(b) As part of the development of an algorithm, a programmer may construct an identifier table.
Describe what an identifier table contains.
…
…
…
… [2]
(c) (i)
Simple algorithms usually consist of three different stages.
Complete the table below. Write each example statement in program code.
The second stage has already been given.
Stage
Example statement
Process
[5]
(ii)
Write a single statement in program code that contains two of the stages. Do not
repeat any of the statements from part (c)(i).
… [1]
(d) A software developer is writing a program and includes several features to make it easier to
read and understand. One of these features is the use of indentation.
State three other features.
Feature 1 …
Feature 2 …
Feature 3 …
[3]
(e) A trace table is often used during program testing.
Identify the type of testing that includes the use of a trace table.
… [1]
Question text
2
(a) (i)
Two types of loop that may be found in an algorithm are the ‘pre-condition’ and ‘post-
condition’ loop.
Identify one other type of loop. Explain when it should be used.
Type …
Explanation …
…
…
[2]
(ii)
Part of a program flowchart is shown.
LOOP
AlarmReset()
Set Status1 to
GetStatus(Sys_A)
Set Status2 to
GetStatus(Sys_B)
Are Status1
NO
and Status2
both TRUE?
YES
Implement the flowchart in pseudocode using a post-condition loop.
…
…
…
…
…
… [4]
(b) The following lines of code are taken from a high-level language program.
100
setvar(Count, Integer)
110
setvar(Gross[0-20], Real)
120
setvar(Posn, Real)
130
setvar(Length, Integer)
140
setvar(Rate, Real)
150
Length := 7
160
Rate := 1.175
170
180
For (Count, 0, 20, 2)
190
{
200
Echo "Input next cost"
210
Posn := Read()
220
Gross[Count] := Mult(Posn, Rate) %Apply current tax rate
230
}
Study the code. Identify the relevant features in the following table.
Feature
Answer
The symbol used to indicate an assignment
The line numbers for the start and end of a count-controlled loop
The step value of the count-controlled loop
The character that indicates a comment
The name of a function
[5]
(c) A program written in a high-level language cannot be run directly.
Identify one type of translator that can be used to translate the program.
… [1]
Question text
3
(a) Programming is sometimes referred to as a transferable skill.
You are asked to work on a program written in a language you are not familiar with.
Explain how transferable skills would help you work on the program.
…
…
…
… [2]
(b) Stepwise refinement is often used in the development of an algorithm.
Describe stepwise refinement.
…
…
…
… [2]
(c) A program needs to search through 1000 elements of an unsorted array to find a given value.
The program will output:
•
either the position in the array of the value
•
or the message “Not Found”
Outline the steps the program needs to follow.
Do not write pseudocode or program code.
…
…
…
…
…
…
…
…
…
…
… [4]
Question 4 begins on the next page.
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]
Question text
2
A 1D array, ClassName, of type STRING contains 100 elements.
The following pseudocode represents a simple algorithm to process the array.
DECLARE SearchValue : STRING
DECLARE FoundFlag : BOOLEAN
DECLARE Index : INTEGER
INPUT SearchValue
FALSE
FoundFlag
1
Index
WHILE Index < 101 AND FoundFlag = False
IF ClassName[Index] = SearchValue
THEN
OUTPUT Index
TRUE
FoundFlag
ENDIF
Index + 1
Index
ENDWHILE
IF FoundFlag = FALSE
THEN
OUTPUT "Not found"
ENDIF
(a) Describe the purpose of the algorithm.
…
…
…
…
…
… [2]
(b) Draw a program flowchart to represent this algorithm.
Note that variable declarations are not required in program flowcharts.
[9]
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]