Compsci Chapters 1 and 2 Notes Compilation
Compsci Chapters 1 and 2 Notes Compilation
[UNIT 2]
MST_CREATOR
Instagram, Twitter, DeviantArt, NG & Tumblr
Data Packets
Data packets are basically blocks of data which join to make up a full file.
Files are split into packets when transferred over long distances.
However, it has drawbacks like needing extra space for the “sequence” value for
reassembly.
Structure
Packet Switching
This is the method where data is broken into packets which can be sent along
pathways independently to each other.
These packets are then sent through many interconnect routers (or nodes) which
eventually reach the receiver.
Hopping
This is to prevent packages from being lost.
Basically, each packet is assigned a “hop number” which is reduced by 1 every time
it “hops” from one node to another.
When this happens, the packet is considered “lost”, is deleted, and then flagged so
that it is resent.
Data Transmission
The 3 Questions
Before we transmit any data, we must ask 3 questions to decide how we even do it:
In Which Direction?
Simplex
This is when data is sent in only 1 direction (e.g., Mouse to computer)
Half-Duplex
This is when data is sent in both directions but not simultaneously (like in walkie
talkies where they say “over” every time).
Full-Duplex
This is when data is sent in both directions simultaneously (like in calls or video calls).
Advantages Disadvantages
Best over long distances. Slow transmitted.
Data is going to arrive completely
synchronised, so it reaches in the right
order.
Advantages Disadvantages
Best over short distances. Data can get skewed over long distances
(data is unsynchronised).
Many bits can be transmitted faster. Expensive due to many wires.
Best for time sensitive data. Requires more hardware.
Easy to use for input/output devices. High interference risk.
Parity Checks
I already made a whole video on this co just watch it here:
https://www.youtube.com/watch?v=oBEblLmUt34
Checksums
As we know, data is sent in blocks.
Each block is assigned a value called a “checksum” which is calculated using the
information stored in that block.
The Process
1. Checksum value is calculated using the block of data.
2. The calculation is done using an algorithm which was agreed on beforehand.
3. The value is then transmitted along with the block of data.
4. The receiver then uses the same algorithm to calculate another checksum.
5. The calculated checksum is compare with the sender’s checksum.
6. If they are the same, no error occurred, if they are not the same, an error had
occurred, and receiver requests the data to be resent.
Echo Check
1. Sender sends data to receiver.
2. Receiver resends the data to the sender.
3. Sender compares the 2 sets of data.
4. If the 2 sets are the same, no error occurred.
5. If they are not the same, then an error occurred in transmission.
The Problem…
This method isn’t very reliable because when we compare the 2 sets of data, we
cannot determine which one is corrupted.
Check Digit
This is the final digit which is included at the end of the data.
ISBN-13
An ISBN code is made up of 13 characters, the 13th character is the check digit.
Generation Rechecking
Add all the numbers at the odd Add all the numbers at the odd
1 1
positions. positions (including check digit).
Add all the numbers at the even Add all the numbers at the even
2 2
positions and multiply by 3. positions and multiply by 3.
Add the results from steps 1 and 2 Add the results from steps 1 and 2
3 3
and divide the result by 10. and divide the result by 10.
If the remainder is 0, then that is the
check digit. If the remainder is 0, then no errors
4 4
If not, then subtract the remainder occurred.
by 10.
Example
Generation Rechecking
(978034098382) (9780340983829)
1 9 + 8 + 3 + 0 + 8 + 8 = 36 1 9 + 8 + 3 + 0 + 8 + 8 + 9 = 45
2 3(7 + 0 + 4 + 9 + 3 + 2) = 75 2 3(7 + 0 + 4 + 9 + 3 + 2) = 75
36 + 75 111 75 + 45 120
3 = = 11 𝑟1 3 = = 12 𝑟0
10 10 10 10
4 10 − 1 = 9 4 𝑅𝑒𝑚𝑎𝑖𝑛𝑑𝑒𝑟 𝑖𝑠 0, 𝑛𝑜 𝑒𝑟𝑟𝑜𝑟𝑠 𝑜𝑐𝑐𝑢𝑟𝑟𝑒𝑑
Modulo-11
Generation Rechecking
Each number is given a weighting
Give each number a weighting (assign
1 1 (assign values from 8-1 from left to
values from 8-2 from left to right).
right).
2 Multiply each digit by its weighting. 2 Multiply each digit by its weighting.
Example
Generation Rechecking
(4156710) (41567102)
4 1 5 6 7 1 0 4 1 5 6 7 1 0 2
1 1
8 7 6 5 4 3 2 8 7 6 5 4 3 2 1
Encryption basically makes the data unreadable meaning that the hacker cannot use
the data even if they steal it.
Cyphertext: This is the plain text which is sent through an encryption algorithm.
Symmetric Encryption
This uses an encryption key which is used to decrypt/encrypt the message.
As of now, we have 10-digit keys, but these are easy to crack which is why we are
moving to longer ones.
Let’s say our encryption algorithm moves the letter forward by a certain value:
L E T M E U S E A C A L C U L A T O R
1 4 5 6 5 3 1 7 4 6 1 4 5 6 5 3 1 7 4
M I U S J X T L E I B P H Z Q D U U V
To decrypt the message, we just move the letters position back by a certain value:
M I U S J X T L E I B P H Z Q D U U V
1 4 5 6 5 3 1 7 4 6 1 4 5 6 5 3 1 7 4
L E T M E U S E A C A L C U L A T O R
The problem is sending this because the hacker can intercept the key as well.
Asymmetric Encryption
This is the confusing and annoying one so understand this well!
Let’s say a user, Ali, wants to send a file to another user, Zain.
The file is encrypted using asymmetric encryption, this is how it would go:
1. Zain uses an algorithm to generate 2 keys (public and private) which are
mathematically linked but cannot be derived.
2. Zain bhai sends his public key to Ali.
3. Ali now uses Zain’s public key to encrypt the file and sends it.
4. Zain now uses his private key to decrypt the document.
Basically, the encryption works in a way such that one key (the public key) is used
for encryption and another key (private key) is used for decryption.
Number Systems
Binary is the basic building block of all computer systems!
The 3 Systems
System Bases Range of Values
Binary 2 0 -1
Denary 10 0 – 9
Hexadcimal 16 0 – 9, A – F
Note!
Conversions will be skipped as I do not know how I can even explain them through
text, I do plan on making some videos on them however!
MAC Addresses
Media Access Control (MAC) address is a term which refers to a number which
uniquely identifies a device on a network.
They are stored inside the Network Interface Card (NIC) & are hardly ever changed.
NN : NN : NN : DD : DD : DD or NN – NN – NN – DD – DD – DD
NN:NN:NN DD:DD:DD
The number of the manufacturer Device serial number
# RR GG BB
RR GG BB
These 2 tell us how much These 2 tell us how much These 2 tell us how much
red is in the colour green is in the colour blue is in the colour
Note!
Addition, subtraction, left shift, and right shift of binary will be skipped as I will
make video(s) on them.
Character Sets
A character set refers to a list of characters that have been defined by the hardware
and software of the computer.
They are important because they enable the computer to understand the characters
we understand.
ASCII Code
This is a character set for all the characters on a standard keyboard & control codes.
It contains 7-bit codes, these codes are used to uniquely identify a character or
control code on a keyboard.
right 0 30 48
<SPACE> 20 32
Extended ASCII
This makes use of 8-bit codes rather than the 7-bit codes used by ASCII code.
This allows it to store 128 more characters, these characters are mainly graphical or
non-English characters.
However, apart from normal English characters, there are more than 128 other
characters.
Unicode
Unicode can support all other languages (including English) & special characters.
It can support a wide range of chars because it can support characters with up to 3
to 4 bytes.
Sound
Soundwaves are vibrations in the air, these vibrations are sensed by our ears and
interpreted as sound.
The amplitude is stored as an approximate value because we cannot find the exact
value.
Tip:
When we are told to get the binary for the amplitude using the given range, we
must find the 2’s power which is more than or equal to the upper bound of the
range.
For example, if we are told that the amplitude range is 1 – 10, we find the 2’s
power where it is greater than or equal to 10, in this case, it is 4 (24 is 16),
meaning that there are 4 digits in which the amplitude is stored.
Key Terms
Sampling Resolution/Bit Depth:
This refers to the number of bits stored by each sample.
Sampling Rate:
This refers to the number of times the sound is sampled per second.
Bit Rate:
Formulas
𝑁𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑆𝑎𝑚𝑝𝑙𝑒𝑠 = 2𝐵𝑖𝑡 𝐷𝑒𝑝𝑡ℎ
𝑆𝑎𝑚𝑝𝑙𝑖𝑛𝑔 𝑅𝑒𝑠𝑜𝑙𝑢𝑡𝑖𝑜𝑛 = 𝐵𝑖𝑡𝑠 𝑃𝑒𝑟 𝑆𝑎𝑚𝑝𝑙𝑒 = 𝐵𝑖𝑡 𝐷𝑒𝑝𝑡ℎ
𝐵𝑖𝑡 𝑅𝑎𝑡𝑒 = 𝑆𝑎𝑚𝑝𝑙𝑖𝑛𝑔 𝑅𝑎𝑡𝑒 × 𝑆𝑎𝑚𝑝𝑙𝑒 𝑆𝑖𝑧𝑒
𝐹𝑖𝑙𝑒 𝑆𝑖𝑧𝑒 = 𝑆𝑎𝑚𝑝𝑙𝑒 𝑅𝑎𝑡𝑒 (𝐻𝑧) × 𝑆𝑎𝑚𝑝𝑙𝑒 𝑅𝑒𝑠𝑜𝑙𝑢𝑡𝑖𝑜𝑛 (𝐵𝑖𝑡𝑠) × 𝐿𝑒𝑛𝑔𝑡ℎ (𝑠) × 𝑇𝑟𝑎𝑐𝑘 𝐴𝑚𝑜𝑢𝑛𝑡
Note:
These formulas are not mentioned in the book (they are from AS levels) but there is
a possibility that you may need to use them in the exam, or at least know what they
mean.
Bitmap Images
Bitmap images are images which are made up of pixels.
Important Terms
Colour Depth:
This refers to the number of bits used to represent each colour.
Image Resolution:
This refers to the number of pixels in the X-Y direction of an image.
Pixel:
This is the smallest element used to make an image on a display.
Important Formulae
Colour Depth:
𝑁𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝐶𝑜𝑙𝑜𝑢𝑟𝑠 = 2𝐶𝑜𝑙𝑜𝑢𝑟 𝐷𝑒𝑝𝑡ℎ
Image Resolution:
𝑅𝑒𝑠𝑜𝑙𝑢𝑡𝑖𝑜𝑛 = 𝐼𝑚𝑎𝑔𝑒 𝑊𝑖𝑑𝑡ℎ × 𝐼𝑚𝑎𝑔𝑒 𝐻𝑒𝑖𝑔ℎ𝑡
File Size:
𝐹𝑖𝑙𝑒 𝑆𝑖𝑧𝑒 = 𝑅𝑒𝑠𝑜𝑙𝑢𝑡𝑖𝑜𝑛 × 𝐶𝑜𝑙𝑜𝑢𝑟 𝐷𝑒𝑝𝑡ℎ
Data Compression
Files like videos and photos are large, this is not good.
To reduce their size we use many techniques, the process of using these techniques to
reduce file size is called “data compression”.
Sound – MP3
MP3 files are sound files and are the compressed versions of the original file.
When a sound file is compressed to MP3, its file size reduces by around 90%.
MP3 files are not of the highest quality (like CD or DVD) but provide a decent
experience to the everyday user.
What Happens
When a file is compressed to MP3, the following may happen:
Video – MP4
This format allows the storage of multimedia; this includes videos, music, sound,
animation, images, etc.
When this is done, they can still be streamed without any reduction in quality.
Images – JPEG
JPEG or Joint Photographic Expert Group is a form of lossy file compression used
with images; it relies on the inability of the eye to distinguish certain colour changes
and hues.
Base Concepts
The system is based off of 2 key concepts:
1. The 1st digit amount of times that data was repeated at a certain position.
2. The 2nd digit is the item which is repeating (letters are shown in ASCII format).
RLE is only useful when the data has repeating values, if not, then the file size may
increase due to the addition of values.
“AAAAbbbbDDDdcccCCCC”
We write the number of times the character was repeated and the ASCII code:
“AbCdEf”
A b C d E f
1 65 1 98 1 67 1 100 1 69 1 102
This contains 12 values while the original has 6.
227 61 111 227 61 111 227 61 111 227 61 111 227 61 111 227 61 111
227 61 111 227 61 111 227 61 111 0 0 0 233 148 58 227 61 111 227 61
111 233 148 58 0 0 0 0 0 0 0 0 0 227 61 111 227 61 111 0 0 0 0 0 0
That monstrosity can be put through RLE and would look like so: