Algorithm design and problem-solving – IGCSE Computer Science (0478)
78 questions · page 1 of 6 · Clear filters
Question text
2
Identify three different types of test data that can be used to test a program.
1 …
2 …
3 …
[3]
Question text
5
A hotel booking system is an example of a computer system that is made up of sub-systems.
The booking system:
•
allows the user to select the room type and the number of nights required
•
displays the types of rooms available to the user as pictures or as a list.
Complete the structure diagram for the given parts of the hotel booking system.
Hotel booking system
[4]
Ĭ×Ċ®Ġ´íÈõÏĪÅĊßü¸Ā×
Question text
7
The flowchart represents an algorithm.
START
Count
0
INPUT Number
Value
Count * Number
IS Value <=
Count
Count + 1
Yes
100 ?
No
Count
Count - 1
OUTPUT Count
STOP
ĬÙĊ®Ġ´íÈõÏĪÅĊàüµĀ×
,
,
(a) Complete the tables, using the flowchart, for the given data:
Input data: 20
Count
Number
Value
Output
Input data: 110
Count
Number
Value
Output
[4]
ĬÛĊ®Ġ´íÈõÏĪÅĊàúµĀ×
,
,
(b) State the purpose of the algorithm on page 8. A copy of the algorithm is provided for you on
page 11.
…
… [1]
(c) State a suitable data type for the variable Count
… [1]
(d) Write the algorithm in pseudocode. A copy of the algorithm is provided for you on page 11.
…
…
…
…
…
…
…
…
… [4]
ĬÙĊ®Ġ´íÈõÏĪÅĊÝü·þ×
,
,
START
Count
0
INPUT Number
Value
Count * Number
IS Value <=
Count
Count + 1
Yes
100 ?
No
Count
Count - 1
OUTPUT Count
STOP
ĬÛĊ®Ġ´íÈõÏĪÅĊÝú·þ×
Question text
9
A school stores all the students’ attendance data in a file called Attendance.txt
Write an algorithm in pseudocode to read a line of text from the file and store this line in the
variable StudentAttendance
…
…
…
…
…
… [4]
Question text
3
A program is written that will only accept values between –99.99 and +99.99, inclusive.
The program is to be tested.
The table, when completed, shows appropriate test data that matches the type of test data and
purpose of the test data.
Complete the table by inserting the missing information.
Test data
Type of test data
Purpose of test data
…
0
…
…
boundary
…
to make sure that the program rejects data that is
outside acceptable limits
[6]
ĬÍĊ®Ġ´íÈõÏĪÅĊàú·Ā×
Question text
5
A program has been written in pseudocode to input five numbers between 1 and 900 inclusive and
store the highest number and the lowest number entered.
900
01
Lowest
1
02
Highest
1 TO 5
03
FOR Count
04
INPUT Number
05
IF Number < Lowest
06
THEN
Number
07
Lowest
08
ELSE
09
IF Number > Highest
10
THEN
Number
11
Highest
12
ENDIF
13
ENDIF
14
NEXT Count
(a) Complete the trace table for the algorithm using the following numbers:
563, 21, 376, 99, 400
Count
Number
Lowest
Highest
[4]
(b) The algorithm does not work correctly.
State the reason why the algorithm does not work as expected and explain how the algorithm
could be corrected.
Any code used must be fully explained.
Reason …
…
Correction …
…
[2]
ĬÏĊ®Ġ´íÈõÏĪÅĊÞü¸Ā×
Question text
6
The flowchart represents an algorithm.
START
Position
–1
Count
1
INPUT Name
IS Name =
Yes
Position
Count
ClassList[Count]
?
No
Count
Count + 1
No
IS Count
> 5 ?
Yes
OUTPUT
Position
STOP
ĬÑĊ®Ġ´íÈõÏĪÅĊßüµþ×
,
,
(a) The algorithm uses the one-dimensional (1D) array ClassList that contains the following
data:
ClassList
1
2
3
4
5
Henil
Sven
Ella
Asia
Ridwan
Complete the table by writing the output from the flowchart when each of the given names are
input.
Name
OUTPUT
Ridwan
Yan
Ella
[2]
(b) Identify the standard method of solution used by the flowchart.
… [1]
(c) Write the algorithm in pseudocode.
…
…
…
…
…
…
…
…
…
…
…
…
… [6]
ĬÓĊ®Ġ´íÈõÏĪÅĊßúµþ×
Question text
7
An algorithm has been written in pseudocode to:
•
input a whole number between 1 and 255 inclusive
•
convert the input to an 8-bit binary number
•
store each bit of the binary number in an array.
For example, if the denary number 127 was input, the binary number 01111111 would be stored in
the array.
01
DECLARE BinaryArray : ARRAY[1:8] OF INTEGER
02
DECLARE DenaryNumber : CHAR
03
OUTPUT "Please enter a whole number between 1 and 255 inclusive "
04
INPUT DenaryNumber
7 TO 1 STEP -1
05
FOR Count
MOD(DenaryNumber,3)
06
BinaryArray[Count]
DIV(DenaryNumber,2)
07
DenaryNumber
08
NEXT Count
(a) Identify the line numbers of the three errors in the pseudocode and suggest a correction for
each error.
Error 1 line number …
Correction …
…
Error 2 line number …
Correction …
…
Error 3 line number …
Correction …
…
[3]
ĬÑĊ®Ġ´íÈõÏĪÅĊÝüµĀ×
,
,
(b) Identify one programming technique used in the algorithm.
… [1]
(c) (i)
The algorithm can accept a number between 1 and 255 inclusive as input.
Two validation checks that could be applied to DenaryNumber are a presence check
and a type check.
Identify one other validation check that could be applied to DenaryNumber
… [1]
(ii)
Write the pseudocode to implement the validation check you identified in (c)(i).
You do not need to rewrite the whole algorithm.
…
…
…
…
…
… [3]
ĬÓĊ®Ġ´íÈõÏĪÅĊÝúµĀ×
Question text
1
Tick (✓) one box to show which check is used for verification when data is input.
A
length check
B
range check
C
type check
D
visual check
[1]
Question text
2
Tick (✓) one box to identify which option is used to show the inputs and output of a Boolean
expression.
A
flowchart
B
trace table
C
truth table
D
variable
[1]
Question text
4
Identify three stages of the program development life cycle from the following list of words.
analysis
decomposition
design
input
pseudocode
testing
variable
1 …
2 …
3 …
[3]
Question text
5
Describe three methods that are used to design and construct a solution to a problem.
Method 1 …
…
…
…
Method 2 …
…
…
…
Method 3 …
…
…
…
[6]
ĬÏĊ®Ġ´íÈõÏĪÅĊßü¸þ×
Question text
9
An algorithm has been written in pseudocode to check if a temperature is in a given range.
The temperature values used in the algorithm are correct.
01 REPEAT
02
OUTPUT "Please enter temperature "
03
INPUT Temp
04
IF Temperature = 999
05
THEN
06
IF Temperature > 38.0
07
THEN
08
OUTPUT "Temperature too high"
09
ENDIF
10
IF Temperature < 35.0
11
THEN
12
OUTPUT "Temperature too low"
13
ENDIF
14
IF Temperature >= 35.0 OR Temperature <= 38.0
15
THEN
16
OUTPUT "Temperature normal"
17
ENDIF
18
ENDIF
19 WHILE Temperature = 999
(a) Identify the line numbers of four errors in the pseudocode and suggest a correction for each
error.
Error 1 line number …
Correction …
…
Error 2 line number …
Correction …
…
Error 3 line number …
Correction …
…
Error 4 line number …
Correction …
…
[4]
ĬÑĊ®Ġ´íÈõÏĪÅĊÞüµĀ×
,
,
(b) Identify the temperature range used.
…
…
… [2]
(c) Complete the trace table for the corrected algorithm using this data:
34.22, 36.1, 37.4, 38.0, 999, –1
Temperature
OUTPUT
[2]
ĬÓĊ®Ġ´íÈõÏĪÅĊÞúµĀ×
Question text
1
Tick (✓) one box to complete this sentence.
A solution to a problem may be represented using pseudocode, flowcharts or
A
procedures.
B
processes.
C
structure diagrams.
D
sub-systems.
[1]
Question text
3
Four flowchart symbols and five purposes are shown.
(a) Draw one line to link each flowchart symbol to its correct purpose.
Not all purposes will be used.
Flowchart symbol
Purpose
subroutine
process
flow
decision
terminator
[4]
ĬÍĊ®Ġ´íÈõÏĪÅĊÝù·þ×
,
,
(b) An algorithm needs to total 50 numbers between 1 and 100 inclusive.
Draw a flowchart that:
•
uses a count-controlled loop from 1 to 50
•
uses an appropriate prompt to ask for a number between 1 and 100
•
totals the numbers as they are entered
•
outputs the total after the loop has completed with an appropriate message.
[6]
ĬÏĊ®Ġ´íÈõÏĪÅĊÝû·þ×