Algorithm design and problem-solving – IGCSE Computer Science (0478)
199 questions · page 11 of 14 · Clear filters
Question text
4
For each of the four checks in the table, place a tick in the correct column to show whether it is an
example of a validation or verification check.
Statements
Validation
Verification
Range check
Double entry
Check digit
Presence check
[4]
Question text
5
Identify and describe three loop structures that are available in pseudocode.
Loop structure 1 …
…
Description …
…
…
Loop structure 2 …
…
Description …
…
…
Loop structure 3 …
…
Description …
…
…
[6]
Question 6 begins on page 14.
Question text
2
(a) An algorithm has been written in pseudocode to input 50 numbers and total only the positive
numbers.
←
1
Count
←
Count
Total
REPEAT
INPUT Number
IF Number <> 0
THEN
←
Total + Count
Total
ENDIF
←
Count + 1
Count
UNTIL Count < 50
PRINT Total
Find the four errors in the pseudocode and suggest a correction for each error.
Error 1 …
Correction …
…
Error 2 …
Correction …
…
Error 3 …
Correction …
…
Error 4 …
Correction …
…
[4]
(b) Show how you would change the corrected algorithm to only total numbers greater than 0
and less than 20.
…
…
… [2]
Question 3 starts on page 10.
Question text
3
This flowchart inputs the type of passenger for a survey: S for Senior, A for Adult, C for Child. All
other values are ignored, apart from Z which ends the process.
START
Senior
0
Adult
0
Child
0
INPUT Type
Yes
Is Type =
Senior
Senior + 1
"S" ?
No
Yes
Is Type =
Adult
Adult + 1
"A" ?
No
Yes
Is Type =
Child
Child + 1
"C" ?
No
No
Is Type =
"Z" ?
Yes
OUTPUT "Seniors ", Senior
OUTPUT "Adults ", Adult
OUTPUT "Children ", Child
END
Complete the trace table for the passenger input data:
S, S, S, A, C, C, C, A, A, A, A, W, S, S, D, C, Z, D, S
Senior
Adult
Child
Type
OUTPUT
[5]
Question text
5
A programmer restricts input values to less than 90 and greater than 60.
(a) State whether this is called validation or verification.
…
Name the check that needs to be used.
…
[2]
(b) State three different types of test data the programmer would need to use. Give an example
of each type and the reason that the programmer chose that test data.
Type 1 …
Example …
Reason …
…
Type 2 …
Example …
Reason …
…
Type 3 …
Example …
Reason …
…
[9]
Question text
2
Six terms associated with programming and six descriptions are listed.
Draw a line to link each term with its most appropriate description.
Term
Description
Pre-written code to include in
Top-down design
your own program to carry out
a common task.
Shows the steps representing
an algorithm using various
Structure diagram
shapes of boxes.
Shows the hierarchy of the
different components which
Flowchart
make up a system.
Shows the values of variables
as you manually test your
Pseudocode
program.
Breaks down a system into
Library routine
successively smaller pieces.
Describes a program using a
Trace table
simplified high-level notation.
[5]
Question text
3
Describe, giving a different example for each, the purpose of these validation checks used in
programming.
Range check …
…
…
Example …
…
…
Length check …
…
…
Example …
…
…
Type check …
…
…
Example …
…
…
[6]
Question text
4
An algorithm is written in pseudocode:
0
Total
1 TO 50
FOR Count
INPUT Num
Total + Num
Total
NEXT Count
OUTPUT Total
(a) Describe the purpose of the algorithm.
…
…
…
…
…
… [3]
(b) Re-write the algorithm in pseudocode using a different type of loop.
…
…
…
…
…
…
…
…
…
… [3]
(c) Describe how you could modify the original algorithm shown at the start of question 4, to
allow any number of inputs.
…
…
…
… [2]
Question 5 starts on page 12.
Question text
5
The flowchart performs a mathematical process on a number input called TestNum
DIV is used to represent integer division e.g. 7 DIV 3 = 2
START
Flag
True
INPUT
TestNum
Num
TestNum – 1
Yes
No
Is Num =
1 ?
Num
Num – 1
Is TestNum /
Yes
No
Flag
False
Num = TestNum
DIV Num ?
Yes
Is Flag =
True ?
No
OUTPUT
TestNum
END
(a) Complete the trace table for the input data: 7
Flag
TestNum
Num
OUTPUT
[2]
(b) Complete the trace table for the input data: 6
Flag
TestNum
Num
OUTPUT
[2]
(c) State the purpose of the algorithm in the flowchart.
…
… [1]
Question text
2
(a) Write an algorithm, using pseudocode, to input three different numbers, multiply the two
larger numbers together and output the result. Use the variables: Number1, Number2 and
Number3 for your numbers and Answer for your result.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
… [5]
(b) Give two sets of test data to use with your algorithm in part (a) and explain why you chose
each set.
Test data set 1 …
Reason …
…
Test data set 2 …
Reason …
…
[4]
Question text
5
The flowchart checks the level of chlorine and the depth of water compared to the height of the
swimming pool. Error messages are output if a problem is found.
START
INPUT Height,
Depth, Chlorine
OK
True
OUTPUT
Yes
Is Depth >
"Water too
Height/2 ?
deep"
No
OUTPUT
Is Depth <
Yes
"Water too
Height/3 ?
shallow"
No
OK
False
OUTPUT "Too
Yes
Is Chlorine
much chlorine
>3 ?
add more water"
No
OUTPUT "Too
Yes
little chlorine
Is Chlorine
add more chlorine"
<1 ?
No
No
Is OK = True ?
Yes
OUTPUT "Pool OK
to use"
END
(a) Complete the trace tables for each set of input data.
Input data: 6, 2.5, 2
Height
Depth
Chlorine
OK
OUTPUT
Input data: 4, 3, 1.5
Height
Depth
Chlorine
OK
OUTPUT
Input data: 6, 3.5, 4
Height
Depth
Chlorine
OK
OUTPUT
[6]
(b) Identify a problem with the algorithm that the flowchart represents.
…
… [1]
Question text
3
Give an example of a pseudocode statement or statements to perform each of the following
functions.
A condition controlled loop …
…
…
A conditional statement …
…
…
Totalling …
…
…
[3]
Question text
5
The algorithm allows a number to be entered. It then calculates and outputs the next number in
the mathematical series.
1
Fib
0
Prev2
1
Prev1
INPUT Number
IF Number = 0
0
THEN Fib
ENDIF
WHILE Number > 2
Prev2 + Prev1
Fib
Prev1
Prev2
Fib
Prev1
Number - 1
Number
ENDWHILE
OUTPUT Fib
(a) Complete the trace table for the input data: 7
Fib
Prev2
Prev1
Number
OUTPUT
[4]
(b) Complete the trace table for the input data: 2
Fib
Prev2
Prev1
Number
OUTPUT
[2]
Question text
2
(a) Write an algorithm to input 1000 numbers. Count how many numbers are positive and how
many numbers are zero. Then output the results. Use either pseudocode or a flowchart.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
Question text
4
A programmer has written a routine to check that prices are below $10.00. These values are used
as test data.
10.00
9.99
ten
Explain why each value was chosen.
10.00 …
…
…
9.99 …
…
…
ten …
…
…
[3]