Revise Edexcel Igcse Computer Science Revision Workbook
Revise Edexcel Igcse Computer Science Revision Workbook
Computer
Science
REVISION
WORKBOOK
REVISE EDEXCEL GCSE (9–1)
Computer Science
REVISION
WORKBOOK
Question difficulty
Look at this scale next to
each exam-style question.
It tells you how difficult the
question is.
www.pearsonschools.co.uk/revise
Contents
Problem-solving Computers
1 Algorithms 47 Input–processing–output
2 Algorithms: pseudo-code 48 The central processing unit
3 Algorithms: flowcharts 49 Components of the CPU
4 Purpose of an algorithm 50 Fetch–decode–execute cycle
5 Completing algorithms 51 Memory
6 Interpreting correct output 52 Magnetic and optical storage
7 Using trace tables 53 Solid-state memory
8 Identifying and correcting errors 54 Cloud storage
9 Linear search 55 Embedded systems
10 Binary search 56 Logic
11 Comparing linear and binary searches 57 Logic circuits
12 Bubble sort 58 Operating system 1
13 Merge sort 59 Operating system 2
14 Decomposition and abstraction 60 Utility software 1
61 Utility software 2
Programming 62 Simulation and modelling
15 Variables and constants 63 Programming languages
16 Arithmetic operators 64 Translators
17 Relational operators
18 Logical operators
Communication and the internet
65 LANs and WANs
19 Selection
66 Client–server and peer-to-peer networks
20 Iteration
67 Wired and wireless connectivity
21 Data types
68 Connecting computers to a LAN
22 String manipulation
69 Data transmission
23 Arrays
70 Protocols
24 File handling operations
71 Network topologies 1
25 Records
72 Network topologies 2
26 Subprograms 1
73 Network security 1
27 Subprograms 2
74 Network security 2
28 Validation
75 Cyberattacks
29 Testing and test plans
76 Identifying vulnerabilities
77 Protecting software systems
Data
78 The internet
30 Using binary
79 The world wide web
31 Converting from denary to binary
32 Converting from binary to denary and binaryaddition The bigger picture
33 Logical shifts 80 Environmental issues
34 Signed integers 81 Ethical impact
35 Arithmetic shifts 82 Privacy issues
36 Hexadecimal and binary 83 Legislation
37 Characters 84 Proprietary and open-source software
38 Bitmap images
39 Sound 85 Practice paper 1
40 Units 93 Practice Paper 2
41 Data compression
104 Answers
42 Run-length encoding
43 Encryption
A small bit of small print
44 Structured and unstructured data Edexcel publishes Sample Assessment Material and the
45 Attributes and tables Specification on its website. This is the official content
46 Relational databases and this book should be used in conjunction with it. The
questions have been written to help you practise every
topic in the book. Remember: the real exam questions
may not look like this.
ii
Problem-
Algorithms
1 (a) What is an ‘algorithm’?
(1 mark)
(b) The three programming constructs used in algorithms are sequence, selection and iteration.
The table below shows an algorithm for authenticating a user’s login name and
password, which allows only three attempts.
Enter sequence, selection or iteration in the blank cell. (5 marks)
(2 marks)
1
Problem-
Algorithms: pseudo-code
1 (a) State what is meant by the term ‘pseudo-code’.
(2 marks)
(b) Write an algorithm to convert an 8-bit binary number into a denary number.
You can assume that the binary number is correctly formatted as 1s and 0s and
has the correct number of digits so that validation is not required.
Use pseudo-code.
The algorithm should examine each of the 8 binary digits and multiply them by their place
values. It should then find the total of these multiplications. See page 32 of the Revision
Guide for a reminder on converting binary to denary.
You will have a copy of the pseudo-code command set in the exam. Make sure your
pseudo-code is clear, concise and accurate, and answers the question.
(6 marks)
2
Problem-
Algorithms: flowcharts
1 The algorithm for a game simulates the throwing of three dice to find the player’s score.
• If all three are equal, then the score is the total of the dice.
• If two are equal, the score is equal to the sum of the two equal dice minus the third.
• If none are equal, then the score is zero.
Here is part of a flowchart for the algorithm.
dice 2
dice 3
Yes Yes
(b) Use the algorithm to calculate the score from the following dice throws.
3 6 3
5 4 5
(2 marks)
(c) It is possible to obtain a negative score using the algorithm.
State three dice numbers which would result in a negative score.
(1 mark)
3
Problem-
!
Purpose of an algorithm
1 Examine the following algorithm. In this algorithm, ‘names’ is an array.
SEND ‘Please enter the first name.’ TO DISPLAY
RECEIVE firstName FROM (STRING) KEYBOARD
SEND ‘Please enter the family name.’ TO DISPLAY
RECEIVE familyName = FROM (STRING) KEYBOARD
SEND ‘Please enter the last two digits of the intake year.’ TO DISPLAY
RECEIVE intYear FROM (INTEGER) KEYBOARD
SEND ‘Please enter tutor group.’ TO DISPLAY
RECEIVE tutorGroup FROM (STRING) KEYBOARD
SET index TO 1
SET unique TO false
WHILE unique = false DO
loginName = intYear & familyName & firstName(0) & tutorGroup & index
FOR check FROM 0 TO LENGTH(names) – 1 DO
IF names[check] = loginName THEN
SET index TO index + 1
ELSE
SET unique TO true
END IF
END FOR
END WHILE
SEND loginName TO DISPLAY
(a) State the purpose of this algorithm.
(2 marks)
(b) State the inputs required by the algorithm.
(4 marks)
(c) An array named ‘names’ is used in the algorithm. State the role of the variable
named ‘check’.
(1 mark)
(d) State the login name for the following: Rosie Cooper in the intake year of 2001
and in tutor group Red. Assume that her login name is unique.
(5 marks)
(e) State four facts that you can deduce about the following student: 02GranthamOBlue3.
(4 marks)
4
Problem-
Completing algorithms
1 Complete the following algorithm which is designed to find the largest of three numbers.
Yes Yes
Yes
(3 marks)
5
Problem-
payment
Yes
£10 note
Complete the flowchart to show how the numbers of £5 notes and £2 and £1 coins
in the change will be calculated. Write your answer in the empty symbols. (9 marks)
6
Problem-
Before you start, read through the algorithm very carefully. Make sure that you understand
what the algorithm is intended to do. That will help you to find the error in the pseudo-
code in part (b).
(a) Identify the data structure used to store the numbers in the list.
(1 mark)
(b) There is an error in the pseudo-code.
(i) State the number of the line in which there is an error.
(1 mark)
(ii) Give the correct version of this pseudo-code.
(1 mark)
(c) Complete the trace table to show the execution of the algorithm if the search
item is 13. You may not need to fill in all the rows in the table.
(5 marks)
7
Problem-
There are five errors in this algorithm. Some are logic errors and some are syntax
errors. Identify the line numbers and correct the errors.
1
2
3
4
5 (5 marks)
8
Problem-
Linear search
1 (a) Describe how a linear search algorithm works.
(2 marks)
(b) David has compiled a list of all the people invited to his party and has stored
the names in an array called partyList.
Write an algorithm in pseudo-code to check whether Elaine’s name is on the list.
Use pseudo-code.
The answer should, if possible, be written in the Edexcel pseudo-code, but you may use
any style of pseudo-code providing its meaning can be understood by a competent
programmer.
(6 marks)
9
Problem-
Binary search
1 Describe the stages of a binary search on a list of items sorted in ascending order.
(4 marks)
(4 marks)
3 Show the stages of a binary search to find the number ‘9’ from the data shown in
this table.
1 6 9 13 15 21 28 36 42 69 76 85 94
(4 marks)
10
Problem-
Yes Yes
Yes
2 (a) When searching a list of 100 items, the largest number of comparisons a linear
search would have to make would be 100.
Show that the maximum possible number of comparisons made using a binary
search of the same list would be 7. Show your working.
(4 marks)
(b) A binary search is generally more eAcient than a linear search. However, this is
not always the case.
Explain why using a linear search may be quicker than using a binary search in
some circumstances.
(2 marks)
11
Problem-
Bubble sort
1 This list of numbers must be sorted
You should label each pass and
into ascending order. remember to compare each pair of
20 15 3 13 9 2 6 numbers and switch them round if
they are not in the correct order.
Show the stages of a bubble sort when
applied to the data shown in the list.
(4 marks)
2 The table below shows an algorithm for carrying out a bubble sort, but the lines are
not in the correct order.
Complete the table to show the correct order of the lines.
12
Problem-
Merge sort
1 The merge sort algorithm divides up a list into smaller and smaller sections and
then sorts them into order before putting them back together again.
Explain the advantage of using this technique.
(2 marks)
2 Use a merge sort to put the data shown below into ascending order.
Show all the stages of the process.
33 25 46 2 8 69 9
(6 marks)
13
Problem-
(1 mark)
(b) Explain why the subprogram ‘computerTurn’ is an example of abstraction.
(2 marks)
(c) When both the player and the computer have made a choice, another
subprogram decides who has won and returns its decision to the main program.
Write an algorithm for this subprogram.
of the player and the computer must be passed to it as parameters and if you are using a
function, whether the player has won or lost must be returned to the main program.
You should add comments to explain your pseudo-code.
(6 marks)
14
Variables and constants
1 Program code makes use of variables and constants.
(a) Explain what is meant by a variable.
(2 marks)
(b) State how a constant differs from a variable.
(1 mark)
(c) State why variables and constants should be given meaningful names.
(1 mark)
(d) The algorithm shown below searches for a value in a list.
1 SET mysteryNumber TO 6
2 SET correct TO False
3 WHILE correct = False DO
4 RECEIVE guess FROM (INTEGER) KEYBOARD
5 IF guess = mysteryNumber THEN
6 set correct to True
7 END IF
8 END WHILE
Complete the table to show the variables used and why they are used in the program.
Read the algorithm carefully to identify the variables and to understand why they
have been used. The first one has been done for you.
(6 marks)
15
Arithmetic operators
1 Calculate the result of the following expression using the correct order of operations.
Show the result of each stage.
The first one has been done for you.
result = 6 * 8 / 2 + (15 – 6) + 3^3
result = 6 * 8 / 2 + 9 + 3^3
(4 marks)
2 Complete the table below by filling in the value of number after each line of code is
executed. The first one has been done for you.
Code Resultnumber
number = 12 + 6 / 2 number = 15
number = 6 * 3 / 2
number = 23 MOD 6
number = 23 DIV 6
number = 6 ^ 2 (4 marks)
3 A number trick asks you to think of a number, double it, add six, divide it in half
and then subtract the number you started with. The result should always be 3.
Write an algorithm using pseudo-code that asks a user to input a number, then carries
out each of the operations and outputs the result.
should see that you will need two variables to store the numbers!
(3 marks)
16
Relational operators
1 Complete the table below by evaluating each of the statements listed and stating whether it is
True or False.
The first one has been done for you.
Statement True/False
7 * 3 <> 10 + 11 False
You first need to work out the
8 + 10 > 8 * 2 results of the calculations and then
9 * 3 <= 10 + 17
10 + 15 >= 6 * 5
9*2=6*3
(5 marks)
2 Alina has sto1red her computer science marks in an array named ‘marks’.
Write an algorithm using pseudo-code that prompts Alina to enter a new mark and
then outputs the number of marks in the array that are:
equal to it
less than it
greater than it.
(6 marks)
17
Logical operators
1 Complete the table below to show the output of each algorithm.
The first solution has been completed for you.
Read and work through the algorithms carefully and write the expected outcome in the
second column.
Algorithm Output
SET number TO 3 Out of range.
IF number > 0 AND number < 2 THEN
SEND ‘Within range.’ TO DISPLAY
ELSE
SEND ‘Out of range.’ TO DISPLAY
END IF
SET number TO 6
IF NOT(number = 3) OR number <> 5 THEN
SEND ‘Number is acceptable.’ TO DISPLAY
ELSE
SEND ‘Number is not acceptable.’ TO DISPLAY
END IF
SET colour TO ‘red’
SET size TO ‘m’
SET price to 25
IF colour = ‘blue’ OR colour = ‘red’ AND size = ‘m’
AND price <= 30 THEN
SEND ‘This would be OK.’ TO DISPLAY
ELSE
SEND ‘Not OK.’ TO DISPLAY
END IF
SET number1 TO 6
SET number2 TO 9
IF (number1 <= 9 OR number2 >=10) AND NOT(number1 *
number2 <50) AND (number2 – number1 = 3) THEN
SEND ‘These numbers are OK.’ TO DISPLAY
ELSE
SEND ‘Not OK.’ TO DISPLAY
END IF
(3 marks)
18
Selection
1 A teacher wants a program that will output a
The algorithm should allow
comment when a mark is input, according to
the teacher to enter a mark
the following rules. and then use comparison
Mark Comment operators to decide the range
the mark is in and display the
90 and above Excellent appropriate comment.
70 to 89 Very good Be careful when you are
selecting the ranges. A mark
60 to 69 Good
can only be put in one range.
50 to 59 Satisfactory
Below 50 Unsatisfactory
Write an algorithm using pseudo-code that prompts the teacher to enter a mark and
then displays the appropriate comment.
(5 marks)
19
Iteration
1 The algorithm shown below searches for a value in a list.
SET list TO [5, 9, 2, 5, 13]
SEND ‘Please enter the search item.’ TO DISPLAY
RECEIVE item FROM (INTEGER) KEYBOARD
SET found TO False
FOR search FROM 0 TO LENGTH(list) -1 DO
IF item = list[search] THEN
SET found TO True
END IF
END FOR
IF found = True THEN
SEND ‘The item is in the list.’ TO DISPLAY
ELSE
SEND ‘The item is not in the list.’ TO DISPLAY
END IF
(4 marks)
20