Y9 Computer Science 2020
Y9 Computer Science 2020
Data Representation
Contents
1) Introduction to binary
2) Denary to binary conversion
3) Binary to denary conversion
4) Binary addition
5) Binary addition Part 2
6) Binary Subtraction
7) Binary Subtraction continued
8) Hexadecimal
9) Hexadecimal continued
10) Exam questions
11) Answers
1|Page
LESSON 1: Introduction to binary
What is binary?
Binary is a number system that only uses two digits: 1 and 0. All information that is processed
by a computer is in the form of a sequence of 1s and 0s. Therefore, all data that we want a
computer to process needs to be converted into binary.
Understanding denary
People use the denary (or decimal) number system in their day-to-day lives. This system has 10
digits that we can use: 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9.
The value of each place value is calculated by multiplying by 10 (ie by the power of 10). The first
few place values look like this:
To convert a binary number to denary, start by writing out the binary place values. In denary, the
place values are 1, 10, 100, 1000, etc – each place value is 10 times bigger than the last. In
binary, each place value is 2 times bigger than the last (ie increased by the power of 2). The first
few binary place values look like this:
128 64 32 16 8 4 2 1
128 64 32 16 8 4 2 1
1 0 1 0 1 0 0 0
128 + 0+ 32 + 0+ 8+ 0+ 0+ 0
In computing, an overflow error can occur when a calculation is run but the computer is unable to store the
answer correctly. All computers have a predefined range of values they can represent or store. Overflow
errors occur when the execution of a set of instructions return a value outside of this range.
2|Page
Task 1:
1) What is binary?
_____________________________________________________________________
_____________________________________________________________________
Task 2:
1- What is an overflow error?
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Glossary of words:
1. binary
A number system that contains two symbols, 0 and 1. Also known as base 2.
2. data
Units of information. In computing there can be different data types, including integers,
characters and Boolean. Data is often acted on by instructions.
3. denary
The number system most commonly used by people. It contains 10 unique digits 0 to 9.
Also known as decimal or base 10.
4. place value
The value of the place, or position, of a digit in a number
3|Page
4|Page
LESSON 2: DENARY TO BINARY CONVERSIONS
TASK 2:
5|Page
LESSON 3: BINARY TO DENARY CONVERSIONS
128 64 32 16 8 4 2 1
128 + 64 + 16 + 4 + 2 + 1
128 64 32 16 8 4 2 1
1 1 0 1 0 1 1 1 = 215 < And that is our answer. We have now converted from binary
into denary.
6|Page
Task 1:
7|Page
Task 2:
8|Page
LESSON 4: BINARY ADDITION
When two numbers are added together in decimal, we take the first number, add the
second number to it, and get an answer. For example, 1 + 2 = 3.
There are four rules that need to be followed when adding two binary numbers. These are:
• 0+0=0
• 1+0=1
• 1 + 1 = 10 (binary for decimal 2)
• 1 + 1 + 1 = 11 (binary for decimal 3)
Example - adding 01 + 10
9|Page
1 + 1 = 0, carry 1
1+0+0=1
0+1=1
1+0=1
1 + 1 = 0, carry 1
1 + 0 + 1 = 0, carry 1
1+0+0=1
1 + 1 = 0, carry 1
1 + 0 + 1 = 0, carry 1
1 + 1 + 1 = 1, carry 1
1+0+0=1
Result in binary - 11001001 (which is decimal 201). You can check your answers by
converting each binary number into decimal and checking your addition. In this example,
01010011 is 83 in decimal and 01110110 is 118 in decimal. So, 83 + 118 is 201.
10 | P a g e
Overflow
Overflow occurs when the result of a calculation requires more bits - place values - than are
in the available range.
For example, when using eight bits, the largest number that can be recorded is 11111111
(decimal 255). When adding together two eight-bit numbers, a situation may occur when
the result requires more than eight bits to hold it. For example, adding the binary numbers
11111110 (decimal 254) and 00000010 (decimal 2) would give:
The result is actually 10000000 (decimal 256), which requires nine bits. However, as only
eight bits are available to hold the number, the result would be 00000000 (decimal 0).
As you can see, overflow can have serious consequences for the validity of calculations.
11 | P a g e
TASK 1:
12 | P a g e
TASK 2:
13 | P a g e
LESSON 5: BINARY ADDITION PT.2
TASK 1:
14 | P a g e
TASK 2:
1)
2)
3)
4)
5)
6)
7)
8)
9)
10)
11)
12)
13)
14)
15)
16)
15 | P a g e
LESSON 6: BINARY SUBTRACTION
Binary Subtraction
The subtraction of the binary digit depends on the four basic operations
0–0=0
1–0=1
1–1=0
10 – 1 = 1
The above first three operations are easy to understand as they are identical to decimal
subtraction. The fourth operation can be understood with the logic two minus one is one.
For a binary number with two or more digits, the subtraction is carried out column by
column as in decimal subtraction. Also, sometimes one has to borrow from the next higher
column. Consider the following example.
0–0=0
1–1=0
16 | P a g e
TASK 1:
17 | P a g e
TASK 2:
18 | P a g e
LESSON 7: BINARY SUBTRACTION CONTINUED
TASK 1:
19 | P a g e
TASK 2:
20 | P a g e
LESSON 8: AN INTRODUCTION TO HEXADECIMALS
The general idea is that for every Hex character you have, you will need one 4bit binary system to convert it into
binary code. To convert this example (1A) you will need to split the ‘1’ and the ‘A’ apart and put them into their own
individual 4bit binary systems, as shown below.
Hex (1) holds the same value as the denary/decimal number 1 and is much the same in binary (0001) (This is how
binary (1) is represented in a 4bit system). Following the same pattern: As you can see from the table above the
example, Hex (A) is equal to the number 10 in denary/decimal and is also equal to 1010 in binary code.
In order to get the full binary code for Hex (1A), you now simply need to combine the two 4bit binary systems as you
see them above. The example below shows you the result:
The two 4bit binary systems have now been combined and one 8bit binary system has now been created as a result.
The key difference between the two 4bit binary systems and the 8bit system, is that the numbers represented in
denary now increment by the power of 2, (like in a normal binary to denary conversion table). However, the results
of ‘1’ and ‘A’ follow the same pattern in the 8bit binary system as they did in the two 4bit binary systems. Therefore,
you have the accurate binary code for Hex (1A). In theory, you can now work out the denary from the 8bit binary
system as well.
Converting Hexadecimal to binary and then to denary, try the questions found over the page.
21 | P a g e
TASK 1: CONVERT THE FOLLOWING HEX NUMBERS INTRO DENARY
Q1) 1B
Q2) AA
Q3) 1F
Q4) 2A
Q5) BB
Q6) 2E
Q7) 3A
Q8) CC
Q9) 3D
Q10) 4A
22 | P a g e
TASK 2: CONVERT THE FOLLOWING HEX NUMBERS INTRO DENARY
Q11) DD
Q12) 4C
Q13) 5A
Q14) EE
Q15) 5B
Q16) 6A
Q17) FF
Q18) 7F
Q19) A0
Q20) 8A
23 | P a g e
WORKING OUT SPACE BELOW
24 | P a g e
LESSON 9: HEXADECIMALS CONTINUED
TASK 1:
TASK 2:
25 | P a g e
LESSON 10: EXAM BASED QUESTIONS
1) A car has many types of embedded systems.
____________________________________________________________________________________________
____________________________________________________________________________________________
____________________________________________________________________________________________
____________________________________________________________________________________________
(ii) The car displays speed limits in denary. Convert the 8-bit binary number 0010 0011 to denary.
____________________________________________________________________________________________
____________________________________________________________________________________________
____________________________________________________________________________________________
____________________________________________________________________________________________
Complete the table to show the result of 0010 0011 + 0100 1010
26 | P a g e
11 ANSWERS:
LESSON 1
TASK 1:
1) Binary is a number system that only uses two digits: 1 and 0. All information that is
processed by a computer is in the form of a sequence of 1s and 0s. Therefore, all data that
we want a computer to process needs to be converted into binary.
2) Denary
3) 0000011
4) Base 2
TASK 2:
In computing, an overflow error can occur when a calculation is run but the computer is
unable to store the answer correctly. All computers have a predefined range of values
they can represent or store. Overflow errors occur when the execution of a set of
instructions return a value outside of this range.
LESSON 2
TASK 1:
27 | P a g e
TASK 2:
28 | P a g e
LESSON 3
TASK 1:
29 | P a g e
TASK 2:
30 | P a g e
LESSON 4
TASK 1:
31 | P a g e
TASK 2:
32 | P a g e
LESSON 5
TASK 1:
33 | P a g e
TASK 2:
1) 251
2) 307
3)341
4)401
5)448
6)493
7)318
8)247
9)277
10)169
11)247
12)253
13)325
14)388
15)378
16)414
34 | P a g e
LESSON 6
TASK 1:
35 | P a g e
TASK 2:
36 | P a g e
LESSON 7
TASK 1:
37 | P a g e
TASK 2:
38 | P a g e
LESSON 8
TASK 1:
39 | P a g e
TASK 2:
LESSON 9
40 | P a g e
TASK 1:
TASK 2:
41 | P a g e
LESSON 10
TASK 1:
1 (i) - 0011 1100
(ii) - 35
(iii) 0110 1101
KEY WORDS –
Binary
Bit
The smallest unit of data – a bit can take the value of ‘0’or ‘1’, alternatively expressed as ‘false’ or
‘true’.
Byte
The smallest addressable unit of data in a computer. Usually 8 bits.
Gigabyte (GB)
1024 megabytes
Kilobyte (kB)
1024 bytes
Megabyte (MB)
1024 kilobytes
Nibble
Half a byte
Terabyte (TB)
1024 gigabytes
Binary
Numbers expressed in base 2.
Decimal (denary)
Numbers expressed in base 10.
Hexadecimal
Numbers expressed in base 16.
Overflow
An error caused by attempting to store a number that is too large for the number of bits available.
42 | P a g e
Designing, Creating and Refining Algorithms
• Computational Thinking
• Decomposition
• Abstraction
• Pattern Finding
• Flowcharts
Computational thinking
This isn’t thinking like a computer (as computers do not think like we do!) but instead it is a thought
process to solving a problem in a way that can be followed by another human or by a machine.
Therefore it is vital we are clear with our instructions so that they can be repeatedly used to solve
problems.
Using computational thinking, we can tackle complex problems and make them more manageable.
Abstraction - Removing extra details so you can focus on the details that matter.
Instructions must be unambiguous which means they must not be open to more than one
interpretation. The instructions must be clear and easily understood. For example, instruction number
5 in the example above clearly states that the bread must be placed vertically into the toaster. If the
word vertically hadn’t been used, then somebody following the algorithm could try to squash the bread
in horizontally.
Algorithms should always be consistent. This means that they will be run the same every time and
produce the same result every time for the same input data. The algorithm above should work for any
piece of bread being used to make toast, but may not work for a different type of toaster.
Algorithms should be efficient. One method of efficiency is that the instructions should solve a
problem in the shortest possible time. In the example above, instructions 7 to 9 are carried out while
the bread is being cooked. If they had been carried out after the toast had finished cooking, then the
whole task would have taken more time.
Whole Solution
Next think about the smaller solutions that need to take place:
Getting equipment
Get toothbrush
Get toothpaste
Find water
Putting toothpaste on toothbrush
Clean toothbrush
Squeeze toothpaste
Cleaning teeth
Scrubbing teeth
Spitting out toothpaste
Swilling mouth with water
Spitting out water
Putting equipment away
Put toothbrush away
Put toothpaste away
This could be also be represented as a diagram:
Clean Teeth
Swill mouth
Find water
with water
Some of these solutions can be re-used. Spitting out toothpaste and spitting out
water will include the same actions. Finding water could be used to solve part
of another problem too.
✓ Each smaller problem is a smaller problem that is easier to solve than the whole problem.
✓ Each smaller problem can be solved independently of the whole problem.
✓ Each smaller algorithm can be tested independently.
✓ The algorithms for the smaller problems can be combined to solve the whole problem.
✓ Some smaller algorithms could be repeated within the solution for the whole problem.
✓ Some smaller algorithms could be re-used to help solve other problems.
✓ Different people can work on solving different smaller problems.
Abstraction
Abstraction is the process of making an easier to understand version of a complex system by focusing
only on necessary information. It is important to identify which information is necessary and ignoring
the information that is not necessary.
Video
Watch this video https://youtu.be/jV-7Hy-PF2Q about abstraction from Robotics
Academy.
Abstraction involves:
Video
Watch this video http://www.bbc.co.uk/education/clips/ztxjrdm about how
abstraction relates to computer algorithms from BBC Bitesize.
A computer programmer will understand how to write code to solve a problem but does not need to
understand how the detail of how the hardware stores and processes the data. A user of the program
will understand how to use the program but does not need to understand how the program was
created.
Activity – truth or lie?
A blue robot which can walk, talk and climb stairs only tells the
truth on Monday, Wednesday and Friday and always lies on all
other days of the week. Today he says: “Tomorrow I will tell the
truth."
a) Tuesday
b) Friday
c) Saturday
d) Sunday
Six frogs are sitting on rocks. Frogs can jump from one rock to another adjacent
empty rock or they can jump over one frog to an empty rock, but they can’t
jump over more than one frog. The frogs can only jump forwards. Send the ABC
frogs to the right-hand side of the pond, and send the xyz frogs to the left-hand
side of the pond. How many moves does it take?
What is the answer to the problem? You can use this interactive puzzle to help
http://www.hellam.net/maths2000/frogs.html solve the problem.
Extension: find a rule (algorithm) to work out the minimum number of moves
needed for any number of frogs on each side.
Example algorithms:
CS4FN puzzles
Turtle tracing
Pseudo code?
Pattern recognition
Pattern recognition involves following the process of abstraction and decomposition to try to identify
patterns that will help to solve problems.
Example – jigsaw
To complete this jigsaw, a child will look for patterns. These patterns
will include:
Corner pieces
Edge pieces
Centre piece
Matching colours
Body parts
Salmon Juice
These are some of the symbols that can be used within a flowchart:
Note: the colours used above are just for illustrative purposes. Colours are not necessary in a
flowchart.
There are lots of tools that you can use to draw flowcharts, including a pencil and ruler or a pencil and
stencil. If you are looking for an online tool then
https://www.draw.io/ is simple to use and moves symbols and arrows around together. You can also
save flowcharts to the cloud or locally. The symbols used in the table above can be found in Basic
Flowchart Symbols.xml which can be opened in draw.io In this chapter, draw.io has been used to create
the flowcharts and all files are in the examples folder, but to show that other tools can also be used,
Microsoft Visio has been used to create the flowcharts in chapter 2.
The algorithm above has a start and an end but there are no decisions. This is
known as a sequence of instructions.
Iterative algorithms also require a decision to be made but the outcome of the decision will enable
processes to repeat.
This is the process that will repeat if the answer to the question is “no”.
This is the question that is asked. If the answer is “no”, the process
repeats. If the answer is “yes”, the algorithm ends. Note that the yes
and no answers could also be the other way around.
Example – central heating
This is a classic example of an iterative loop. It is
for a central heating system that is constantly
running. The question that is asked is whether
the temperature is less than 21o Celsius. If it is,
then the heating is turned on and the question is
asked again. If it isn’t, then the heating is turned
off and the question is asked again.
Example – countdown
Flowcharts are used for programming concepts such as
sequence, selection and iteration in chapter 2. In this chapter,
the focus is just on the use of flowcharts for everyday
algorithms, but this is an example of an algorithm that could be
represented as a computer program.
This algorithm asks the user how many numbers they want to
countdown. The user gives an answer, eg 10. The algorithm
then displays the value (eg 10), and reduces the value by 1. If it
has reached 0, it stops. If it hasn’t reached 0, then it displays
the new value, eg 9 and keeps repeating this until the value is 0.
Pseudo-code
REPEAT
OUTPUT counter
counter ← counter – 1
UNTIL counter = 0
Algorithms may just include sequence, or they may include selection and may also include iteration.
When lots of decisions need to be made, the algorithm can become quite complex. Looking at the
algorithm visually as a flowchart can help to understand the purpose of the algorithm and how it works.
Example – snap
This algorithm for a
game of snap uses all of
sequence, selection and
iteration.
Name: ______________________________
Teacher: _____________________________
School: ______________________________
What is a network?
A computer network is a number of computers linked together to allow them to share
resources. Networked computers can share hardware, software, and data.
Most computer networks have at least one server. A server is a powerful computer that
provides one or more services to a network at its users. For example, file storage and email.
Network types
A LAN covers a small area such as one site or building, e.g. a school or college.
Advantages
Sharing devices such as printers saves money.
Site (Software) licenses are likely to be cheaper than buying several standalone
licenses.
Files can easily be shared between users.
Network users can communicate by email and instant messenger.
Security is good – users cannot see other users’ files unlike on stand-alone
machines.
Data is easy to backup as all the data is stored on the file server.
Disadvantages
Questions:
1. A school with 20 stand-alone PC’s is considering networking them together and
adding a file server. Describe FOUR possible benefits of doing this.
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_______________________________________
In a bus network all the workstations, servers and printers are joined to one cable (the bus).
At each end of the cable a terminator is fitted to stop signals reflecting back down the bus.
Advantages Disadvantages
Ring network:
In a ring network each device (workstation, server, printer) is connected to two other
devices, this forms a ring for the signals to travel around. Each packet of data on the
network travels in one direction and each device receives each packet in turn until the
destination device receives it.
Advantage Disadvantage
This type of network can transfer data If the main cable fails or any device is
quickly, even if there are a large faulty then the whole network will fail.
number of devices connected because
the data only flows in one direction, so
there won’t be any data collisions.
Star network:
In a star network each device on the network has its own cable that connects to a switch or
hub. A hub sends every packet of data to every device, whereas a switch only sends a
packet of data to the destination device.
Advantages Disadvantages
Questions:
1. Draw a ring network below:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
5. Draw a bus network below:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
8. Draw a star network below:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Network components
A modem enables a computer to connect to the internet over a telephone line. A modem
converts digital signals from a computer to analogue signals that are then sent down the
telephone line. A modem on the other end converts the analogue signal back to a digital
signal which another computer can understand.
Routers are used to join networks of different types together such as a fibre optic cable to a
wireless home network.
Switches are used to direct messages to the correct computer along cables in a network.
Hubs send signals to all devices connected on the network.
Network Interface Card (NIC) allows connection and generates a unique IP address for the
device.
Transmission media could include cables such as copper or fibre optic and wireless signals.
A Wireless Access Point (WAP) boosts the capabilities of a wireless network to solve the
problem of “dead spots” where the signal is low due to location or environmental factors.
Servers:
The network relies on a central server and all the clients (devices) request services from the
server such as print services, file services etc. Additional hardware is needed in this type of
network as, for example high end powerful servers will need to be purchased. All files can
be stored and backed-up centrally on a client server which means workers can access files
from any computer on the network and the computers can also be updated from a central
database.
Peer-to-peer:
All computers have equal status and each computer can act as a client and a server. All
computers can request and provide network services, even if only one computer is
physically attached to the printer other computers on the network can still send data to the
printer themselves.
Questions:
Data and software is stored and backed up remotely over a computer network by an
independent company.
The Internet
The internet is made of computers connected to each other around the world.
Words and pictures can be sent from one computer to another. You can look at words and
pictures from a computer on the other side of the world.
When we connect to the internet, we are said to be ‘online’. Today the internet has many
online facilities, for example:
When you use websites and some apps, you are using the internet.
When you send an email to someone else, you are using the Internet.
When you watch a video on Youtube, you are using the Internet.
Watches - New smart watches can connect to the Internet by using a mobile phone or WiFi
network.
Books - Paper books cannot connect to the Internet but new ‘e-book’ tablets can, to
download books, magazines and newspapers.
Cameras - Many new digital cameras can connect to the Internet via WiFi. They make it
easy for you to share your photos on websites.
Websites are accessed using a web browser. A browser is a program designed to display the
information held on a website. Every website has an address at which it can be found, a bit
like a house address.
A website’s address is known as its URL. A website can be visited by typing its URL into a
web browser.
Questions:
1. If you want to access your files from many devices, where should you store them?
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
2. Describe 3 things that you use the Internet for.
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
3. What is the difference between the Internet and the World Wide Web?
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________