0% found this document useful (0 votes)
104 views42 pages

CompSci A2 Paper 3

Uploaded by

tt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
104 views42 pages

CompSci A2 Paper 3

Uploaded by

tt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

1

13. Data Representation

Explain what is meant by a user-defined data type, Include an example:

● A data type constructed by a programmer // not a primitive data type


● A data type that references at least one other data type, the
● types can be primitive or user defined.
● Class/object/set

Describe the purpose of a user-defined data type:

● To create a new data type (from existent data types)


● To allow data types not available in a programming language to be constructed //
To extend the flexibility of the programming language

Describe how records are organized and accessed in a sequential file:

● Records are stored in a particular order


● The order is determined based on the value of the key field
● Records are accessed one after the other
● Records can be found by searching from the beginning or the file, record by record
until the required record is found or key value is exceeded.

Describe what is meant by composite and non–composite data types:

● Composite: A data type that is a collection of data that can consist of multiple
elements of different or the same data types grouped under a single identifier
● Non-composite: It can be defined without referencing another data type and it can
be a primitive type available in a programming language, or a user-defined type.

Describe what happens in relation to storage or retrieval of a record in the file, when the
calculated hash value isca a duplicate of a previously calculated hash value for a different
record key.

● A collision occurs when the record key doesn’t match the stored record key, this
means the determined storage location has already been used for another record.
● If the record is to be stored:
○ Search the file linearly, to find the next available storage (closed hash)
2

○ Search the overflow area linearly, to find next available storage space
(open hash)
● If the record is to be found:
○ Search the overflow area linearly (open hash) until the matching record key
is found
○ Search linearly from where you are (closed hash) until the matching record
key is found
○ If not found record is not in file

Composite User -Defined Data Types:

Record Data Type:


TYPE TAppointments
DECLARE Name : STRING
DECLARE DOB : DATE
DECLARE Telephone : INTEGER
DECLARE LastAppointment : DATE
DECLARE FirstAppointment : DATE
DECLARE TreatmentCompleted: BOOLEAN
ENDTYPE

Set Data Type:


TYPE Days = SET OF STRING
DEFINE Today(Monday, Tuesday, Wednesday, Thursday, Friday…) : DAYS

Non-Composite User-Defined Data Types (Non-composite user-defined data types don’t


involve a reference to another type. When a programmer uses a simple built-in type, the
only requirement is for an identifier to be named with a defined type.):

Enumerated Data Type (A user-defined non composite data type with an ordered
list of possible values):
TYPE Season(Summe, Winter, Autumn, Spring)
DECLARE ThisSeason : Season
DECLARE NextSeason : Season
ThisSeason ← Autumn
NextSeason ← ThisSeason + 1 // NextSeason is set to Spring

Pointer Data Type (A user defined non composite data type used to reference to
a memory location):
3

Using this diagram we can say that:


IPointer: 4402 (This is the address IPointer is pointing to)
IPointer^: 33 (This is the value stored at the address 4402)
@Myint1: 3427 (This is the address of MyInt1)
IPointer^=MyInt2: True, this compares the values at MyInt2 and the pointer.
Some examples we can do:
1. Place the address of MyInt2 in the pointer.
IPointer ← @MyInt2
2. Assign the value 33 to the variable MyInt1
MyInt1 ← 33
3. Copy the value of MyInt2 into the memory location currently pointed at by the
IPointer.
IPointer^ ← MyInt2
If I want to create a pointer to reference the memory location of which the
current part is stored (computer parts for clarification).
Type Parts = (Monitor, CPU, SSD, HDD, LaserPrinter, Keyboard, Mouse)
Type SelectParts = ^Parts

State the consequence of storing the binary number as a floating point number in this
system. Justify your answer. (Note: This only applies to specific scenarios where the
original number of bits is larger then the bits provided for the mantissa, for this
question I'll be using original 14 bits with sign and 12 bits mantissa):
4

● Consequence: The precision/accuracy of the number would be reduced


● Justification: Because the least significant bit of the original number has been
lost/truncated (This is also called a bit underflow as it is too accurate to be
properly represented by the computer), the original number had 14 bits with sign
but the mantissa can only store 12 bits.

Explain the reason why binary numbers are stored in normalized form:

● To store the maximum range of numbers in the minimum number of bytes/bits


● Normalization minimizes the number of leading zeros/ones represented
● Maximizing the number of significant bits/maximizing the potential accuracy of the
number for the given number of bits
● Enables very large /small numbers to be stored with accuracy.
● Avoids the possibility of many numbers having multiple representations

I can’t explain the process of converting properly (Binary to mantissa & exponent) over
text so watch these 2 videos:

● https://youtu.be/mGfOJQgdI_U?si=NIJfrGzOkIsSxUdt
● https://youtu.be/IGQ9YOnhWxA?si=bUpyNU2QipPoI9ah

Compare sequential and serial methods of file organization:

● In both serial and sequential files records are stored one after the other and need
to be accessed one after the other
● Serial files are stored in chronological order
● Sequential files are stored in ordered records and stored in the order of the key
field
● In serial files, new records are added to the next available space/records are
appended to the file
● In sequential files, new records are inserted in the correct position

Advantages of serial file organization:

● No need to re-sort data every time new data is added


● Only a small file so searching will require little processing
● New records can easily be appended
● Allows data to be read in the order they were taken/stored (CONTEXT BASED
ANSWER)
● Stored in chronological order
5

Disadvantages of serial file organization:

● It becomes difficult to access because you must access all proceeding records
before retrieving the one being searched.
● It cannot support modern high-speed requirements for quick record access.
● File access: Records in this file type are searched using Sequential Access.
Successively read record by record until the required data is found or the whole file
has been searched, and the required data is not found, thus prolonging the process

Advantages of sequential file organization:

● The sorting makes it easy to access records but does not remove the need to
access other records as the search looks for particular records.
● The binary search technique can reduce record search time by half the time.

Advantages of random files organization(Records are stored randomly in the file but are
accessed directly. The location for each record is found using a Hashing Algorithm on the
record's key field. Magnetic and optical disks use random file organization.):

● Quick retrieval of records.


● The records may vary in size.

Direct access/random access files:

● It's well suited for larger files, which take longer to access sequentially. Data in
direct access files are stored in an identifiable record, which could be found by
involving initial direct access to a nearby record followed by a limited serial search.

Factors that determine the file organization use:

● How often do transactions occur, and how often does one need to add data?
● How often does it need to be accessed, edited, or deleted?

Most suitable method of file access when a record is referenced by a unique address on a
disk type storage medium:

● Direct access

14. Communication and Internet Technologies

State, with a reason, where it would be appropriate to use circuit switching:


6

● Circuit switching is used where a dedicated path needs to be sustained throughout


the call//where the whole bandwidth is required.
● A typical applicant is standard voice communication / video streaming / private
data networks

Advantages of circuit switching:

● Whole of bandwidth is available


● Dedicated communication channel increases the quality of transmission
● Data is transmitted with a fixed data rate
● No waiting time at switches
● Sustainable for long continuous communication
● Fast method of data transfer
● Data arrives in the same order as it was sent
● Better for real time
● Data all follows the same path
● Simple method for data transfer

Disadvantages of circuit switching:

● A dedicated connection makes it impossible to transmit other data even if the


channel is free
● Not very flexible
● No alternative route in case of failure
● The time required to establish the physical link between the two stations can be
long
● The need to establish a dedicated path for each connection can have cost
implications
● Dedicated channels require the whole bandwidth

Examples of where it would be appropriate to use packet switching:

● Most commonly used on data networks such as the internet to send large data
files that don’t need to be streamed
● Is used when it is necessary to be able to overcome faulty lines by rerouting
● Used when communication needs to be more secure
● High volume data transmission
● Used when isn’t necessary to use all of the bandwidth
● Any specific examples like (email, text messages, documents, etc)
7

Differences between circuit switching and packet switching:

● Circuit switching uses a dedicated channel to make communication, where as


packet switching forms data into packets to transmit over a digital network
● Dedicated path for circuit switching must be established before the transfer of
data can commence, which is not the case with packet switching
● Data in packet switching is split into packers, in circuit switching messages remain
the same
● All the transmission in circuit switching follow the same path whereas different
packets in packet switching can take different routes
● Messages received in same order in which it is sent for circuit switching but in
packet switching may be received out of order (assembly at destination)
● Circuit switching is a simpler process than packet switching

Outline the function of the TCP protocol suite:

● The transport layer breaks data into manageable packets


● Adds a packet header
● Sends packets to the internet // network layer // receive data from application layer
● Controls the flow of packets
● Handles packet loss/corruption

Outline the function of the IP protocol suite:

● The internet layer identifies the intended network and host


● Transmits packets to the physical layer
● Routes the packet independently through the optimum route
● Addresses packet with their source and destination IP addresses
● Then Uses an IP address and port number to form a socket

Explain why protocol is used between computers:

● Protocols set a standard for communication


● Protocols enable communication between devices from different platforms
● If two devices were sending messages but using different protocols, they would
not be able to communication party

Diagram for the TCP/IP protocol stack:


8

Only need to know up to the link layer in the syllabus

Describe the purpose of the IMAP protocol:

● Used by email clients to retrieve email messages (a pull protocol) from a mail
server (over a TCP/IP connection)
● Keep the server and client in sync by not deleting the original email

Describe circuit switching:

● A dedicated circuit
● Circuit is established before transmission starts // circuit is released after
transmission ends
● Data is transferred using the whole bandwidth
● All data is transferred over the same route

Describe packet switching:

● Data is split into packets


● Each packet is given its own route
● The routing for a packet depends on the congestion
● Packets may not arrive in the order sent

2 interconnected questions will be bolded

The TCP/IP protocol suite has 4 layers, the application layer provides user services.
Identify the protocols used by this layer and describe:

● HTTP(S): For sending and receiving web pages (HyperText Transfer Protocol)
● FTP: For sending and receiving files over a network (File Transfer Protocol)
● SMTP: For sending/uploading emails / push protocol (Simple Mail Transfer
Protocol)
● POP3: For receiving/downloading emails / pull protocol (Post Office Protocol 3)
● IMAP: For receiving/downloading emails / pull protocol (Internet Message Access
Protocol (Alternative to POP3))

Identify the other layers of the TCP/IP protocol suite. Describe the function of each
layer:

● Transport: Handles packets


● Internet: Handles transmission of data using IP addresses // provides optimal route
9

● Network Access Interface / Link: Handles how data is physically sent

Describe the TCP/IP protocol suite:

● A layered model/stack with 4 layers


● Uses a set of protocols for transmission of data, transport control protocol with
internet protocol
● Named layers such as application, transport, internet, link in the correct order

Explain how packet switching is used to transfer messages across the internet:

● A large message is divided up into a group of smaller chunks of the same size
called packets
● The packet has a header and a payload
● The header contains a source IP address, destination IP address (and sequence
number)
● Each packet is dispatched independently and may travel along different routes /
paths
● The packets may arrive out of order and are reassembled into the original message
at the destination
● If packets are missing / corrupted a re-transmission is requested

Outline the function of a router in packet switching:

● The router examines the packet’s header


● It reads the IP address of the destination (from the packet header)
● A router has access to a routing table containing information about available hop /
netmasks / gateway used / etc
● And the status of the routes along the route
● The router decides on the next hop and sends the packet on its next hop

Advantages of packet switching:

● Accuracy - Ensures accurate delivery of the message


● Completeness - Missing packets can be easily detected and a resend request sent
so the message arrives complete
● Resilience - If a network changes the router can detect this and send the data
another way to ensure it arrives
10

● Path is also available to other users / Doesn’t use whole bandwidth


● Better security as packets hashed and sent by different routes

Disadvantages of packet switching:

● Time delays to correct errors / Network problems may introduce errors to packets
● Requires complex protocols for delivery
● Unsuitable for real time transmission applications

Explain how applications use BitTorrent to exchange data:

● BitTorrent client software made available


● A computer joins a swarm by using the BitTorrent software to load a Torrent
descriptor file
● A server called a tracker that keeps records of all the computers in the
● swarm
● And shares their IP addresses allowing them to connect to each other
● One computer in the swarm must have a complete copy of the torrent to be
● shared
● Torrent is split into small pieces
● Pieces of the torrent are both downloaded and uploaded
● Once a computer has a piece it can become a seed and upload
● Leeches download much more than they upload

Using the TCP/IP protocol suite, what happens when a message is sent from host to
another (In the syllabus you only need to know up to the link layer, physical layer is here
for understanding):

● Sender side (Application Layer): Encodes the data in an appropriate format


● Sender side (Transport Layer): The data to be sent is broken down into smaller
chunks known as packets
● Sender side (Network Layer): IP addresses (sender and receiver) and a checksum
are added to the header
● Sender side (Link Layer): Formats the packets into a frame. These protocols attach
a third header and a footer to frame the packet. The frame header includes a field
that checks for errors as the frame travels over the network media.
11

● Sender side (Physical Layer): Receives the frames and converts the IP addresses
into the hardware addresses appropriate to the network media. The physical
network layer then sends the frame out over the network media.
● Service Provider: Re-routes the packets according to the IP address
● Receiver side (Physical Layer): Receives the packet in its frame form. It computes
the packet's checksum and sends the frame to the data link layer.
● Receiver side (Link Layer): Verifies that the checksum for the frame is correct and
strips off the frame header and checksum. Finally, the data link protocol sends the
frame to the Internet layer.
● Receiver side (Network Layer): Reads information in the header to identify the
transmission and determine if it is a fragment. IP would reassemble the fragments
into the original datagram if the transmission was fragmented. It then strips off the
IP header and passes it on to transport layer protocols.
● Receiver side (Transport Layer): Reads the header to determine which application
layer protocol must receive the data. Then TCP strips off its related header and
sends the message or stream up to the receiving application.
● Receiver side (Application Layer): Receives the message and performs the
operation requested by the sender
● Note, LINK is just a combination of data link and physical
● https://www.youtube.com/watch?v=OTwp3xtd4dg (Nice explanation :))

AS content such as CSMA, topologies and stuff can be found here:


https://docs.google.com/document/d/1XLgViSAGlhHU8r5IFmD0xn10TnZ8H13S3jD26GfJ
YFA/edit (P.S These are not my notes and are just some that I found for AS lvl)

15. Hardware and Virtual Machines

A processor will have an architecture which refers to its physical construction, a process
will also have what is termed an ‘Instruction set architecture’. This is concerned with:
• the instruction set
• the instruction format
• the addressing modes
• the registers accessible by instructions

Complex Instruction Set Computer (CISC): a single instruction can be more complex and
involve more loading of data from memory

Reduced Instruction Set Computer (RISC): a single instruction is simpler, requiring


minimal loading of data from memory
12

RISC CISC

Fewer instructions More instructions

Simpler instructions More complex instructions

Small number of instruction formats Many instruction formats

Single-cycle instructions whenever Multi-cycle instructions


possible

Fixed-length instructions Variable-length instructions

Only load and store instructions to Many types of instructions to address


address memory memory

Fewer addressing modes More addressing modes

Multiple register sets Fewer registers

Hard-wired control unit Both hard-wired and microprogrammed


control unit

Pipelining easier Pipelining more difficult

Uses a system where cache is split Makes use of cache


between data and instruction

Some extra notes on CISC & RISC:

● For RISC the term reduced affects more than just the number of instructions, as the
reduction in the number of instruction is not the major driving force for the use of
RISC, but it is the reduction of the complexity of the instruction that's the key
feature of RISC
● The typical CISC architecture contains many specialized instructions, the
specialized instructions are designed to match the requirement of a high-level
programming language, they require multiple memory accesses which are very
slow compared register accesses

Pipelining: Instruction-level parallelism (The underlying principle of pipelining is that the


fetch-decode-execute cycle can be separated into a number of stages, one possibility is a
five stage model consisting of (processing units):
13

TABLE FOR IT IS NEXT PAGE:

Row: Clock cycles 1 2 3 4 5 6 7



Column: Processing
units ↓

Instruction fetch (IF) 1.1 2.1 3.1 4.1 5.1 6.1 7.1

Instruction decode 1.2 2.2 3.2 4.2 5.2 6.2


(ID)

Operand fetch (OF) 1.3 2.3 3.3 4.3 5.3

Instruction execute 1.4 2.4 3.4 4.4


(IE)

Result write back 1.5 2.5 3.5


(WB)

Now what if a question asks to put 6 instructions for example in a table with 12 clock
cycles and five stages, this is how it would be done:

1 2 3 4 5 6 7 8 9 10 11 12

IF 1.1 2.1 3.1 4.1 5.1 6.1

ID 1.2 2.2 3.2 4.2 5.2 6.2

OF 1.3 2.3 3.3 4.3 5.3 6.3

IE 1.4 2.4 3.4 4.4 5.4 6.4

WB 1.5 2.5 3.5 4.5 5.5 6.5

Without pipelining this processes would've been 5 times longer


14

Describe the use of pipelining in Reduced Instruction Set Computers (RISC):

● Pipelining allows several instructions to be processed simultaneously therefore,


increasing the CPU instructions throughput/the number of instructions completed
per unit time
● Each instruction stage is completed during one clock cycle
● No two instructions can execute their same stage of instruction / subtask at the
same clock cycle
● For example while one instruction is being decoded, the next instruction can be
fetched and so on

Describe the process of pipelining during the fetch-execute cycle in RISC processors:

● Instructions are divided into subtasks / 5 stages (IF, ID, OF, IE, WB)
● Each subtask is completed during one clock cycle
● No two instructions can execute their same stage at the same cycle
● The second instruction begins in the second clock cycle, while the first instruction
has moved on to its second subtask
● The third instruction begins in the third clock cycle while the first and second move
on to their second and third subtask respectively and so on

One disadvantage of pipelining is interrupt handling as there will be 5 instructions in the


pipeline when an interrupt occurs:

● Erase the pipeline content for the latest 4 instructions to have entered. Then, the
normal interrupt handling routine can be applied to the remaining instruction
● Construct the individual units in the processor with the individual program counter
registers. This allows current data to be stored for all of the instructions in the
pipeline while the interrupt is handled

SISD: Single Instruction Stream Single Data stream; a single processor accessing one
memory, found in early computers (Cheap, low power, microprocessors slow speed,
battery solar power systems)

SIMD: Single Instruction Stream Multiple Data stream; processing of parallel data input
requiring one control unit instructing multiple processing units, found in array processors
(Efficient on large amount of data, modern GPUs, scientific process limited)
15

MISD: Multiple Instruction Stream Single Data stream; does not exist in a single
architecture, used to sort large quantities of data, contains multiple processors which
process the same data

MIMD: Multiple Instruction Stream Multiple Data stream; multiple processors


asynchronously processing parallel data input, found in modern computers , each
processor executes a different individual instruction (complex and expensive, processes a
lot of data very fast, real-time fault detection, double checks things)

Outline the characteristics of massively parallel computers:

● Computers that contain vast amounts of processing power. A large number of


computer processors / separate computers connected together simultaneously
performing a set of coordinate computations
● Has a bus structure to support multiple processors and a network infrastructure to
support multiple ‘Host’ computers.
● Communicate using a message interface
● Commonly used to solve highly complex mathematical problems.

Describe what is meant by a virtual machine:

● The emulation of a computer system/hardware and/or software using a host


computer system
● Using guest operating system for emulation
16

Pros Cons

Different instruction set architectures can A virtual machine is less efficient/has


be emulated on a single computer poorer performance than real machines
because of the extra load on the host
computer

A virtual machine can crash without The time, effort and cost needed for
affecting the host machine implementation is high

Can run legacy applications that are Performance of the guest system cannot
currently incompatible be adequate measured

There are security benefits as a virus A virtual machine may be affected by any
would only infect the virtual machine weakness of the host machine

Cost savings due to not needing to Cannot emulate some hardware


purchase extra hardware

More than one new computer system can Use of a virtual machine increases the
be emulated so allows for multiple OS to maintenance overheads because both the
exist host system and virtual machine must be
maintained

Examples and Usage:

● Used by companies wishing to use the legacy software on newer hardware and
server consolidation companies
● Virtualizing machines allows developers to test applications on many systems
without making expensive hardware purchases

Combinational circuit (A circuit whose output is dependant only on the input values):

Half adder: This is the simplest circuit that can be used for binary addition, the circuit
takes in two bits and outputs a sum bit (S) and a carry bit (C). So how would that work? If
you are adding 1 0 or 0 1, sum bit is 1 and carry bit is 0, however if you are adding 1 1, the
sum bit is gonna be 0 and the carry bit is 1 as it is being carried forward. So a half adder
truth table would be something like this:
17

A (INPUT) B (INPUT) S (OUTPUT) C (OUTPUT)

0 0 0 0

0 1 1 0

1 0 1 0

1 1 0 1

You can see the truth table for the S output can be seen as a match for the XOR operator,
therefore we can say one circuit that would produce the half adder functionality would
contain an AND gate and an XOR gate, with each gate receiving input from A and B. This
is only one of the several circuits that would provide the functionality. The NAND and
NOR gates are universal gates, any logic circuit can be constructed using only NOR or
NAND gates.

A half adder circuit constructed purely using NAND gates

Now moving on to the full adder, if a half adder is used each time, there has to be a
separate circuit to handle the carry bit because the half adder only takes in 2 bits. This is
where the full adder comes in with 3 inputs including the previous carry bit. The truth
table for a full adder would be something like this:

A (INPUT) B (INPUT) Cin (INPUT) S (OUTPUT) Cout (OUTPUT)

0 0 0 0 0

0 0 1 1 0

0 1 0 1 0
18

0 1 1 0 1

1 0 0 1 0

1 0 1 0 1

1 1 0 0 1

1 1 1 1 1

Some possible implementations of a full adder:


19

The SR flip-flop is a simple example of a sequential circuit, it can be constructed using


two NAND gates or two NOR gates, for example

This circuit is a self-consistent state, if we consider the state with Q=1 and Q’=0:
• and we consider the condition that both S and R inputs are 0
• then the top NOR gate has inputs both 0
• giving output 1
• and the bottom NOR gate has inputs 1 and 0
• giving output 0

The S and R inputs are for set and reset respectively, we can showcase a truth table to
see how S and R change the initial state to a new final state:

S (INPUT) R (INPUT) Q (INITIAL) Q’ (INITIAL) Q (FINAL) Q‘ (FINAL)

0 0 1 0 1 0

1 0 1 0 1 0

0 1 1 0 0 1

0 0 0 1 0 1

1 0 0 1 1 0

0 1 0 1 0 1

A combination of S=0 and R=1 converts a set state to an unset state, a combination of
S=1 and R=0 converts an unset state to a set state.
20

The purpose of a flip-flop is to store a binary digit, and so memory can be created from
flip-flops, and flip-flops can be used to store bits of data

In addition to the possibility of entering an invalid state there is also the potential for a
circuit to arrive in an uncertain state if inputs do not arrive quite at the same time. In order
to prevent this, a circuit may include a clock pulse input to give a better chance of
synchronizing inputs. The JK flip-flop is an example

A represents the symbol of JK flip-flop while B represents a possible circuit of the JK


flip-flop.

J K Clock Q

0 0 ↑ Q unchanged

1 0 ↑ 1

0 1 ↑ 0

1 1 ↑ Q toggles (Q and Q’
is switched)

This subtopic can be confusing so here is a couple videos on this as well:

● https://www.youtube.com/watch?v=j6krFp511HA (JK flip-flop)


● https://www.youtube.com/watch?v=6kdtXF_j8Qg&pp=ygUec3IgYW5kIGprIGZsaX
AgZmxvcCBBIGxldmVsIGNz (Past paper working)
21

● https://www.youtube.com/watch?v=G35mcLX-vh0&pp=ygUec3IgYW5kIGprIGZsaX
AgZmxvcCBBIGxldmVsIGNz (SR flip-flop)
● https://www.youtube.com/watch?v=fJakGU0vCg8&pp=ygUec3IgYW5kIGprIGZsaX
AgZmxvcCBBIGxldmVsIGNz (JK flip-flop)
● https://www.youtube.com/watch?v=j6krFp511HA (JK flip-flop)

There are two problems with the SR flip-flop that the JK flip-flop overcomes.
State each problem and state why it does not occur for the JK flip-flop:

● Problem 1
○ One combination of S and R gives NOT valid / indeterminate output // Q
○ and Q have the same value
○ The JK flip-flop does not allow for Q and Q to have the same value for
○ any combination of inputs // Q and Q have to be complementary
● Problem 2
○ Inputs may not arrive at the same time
○ The JK flip-flop has a clock pulse to synchronize inputs

Identities for boolean algebra:

Karnaugh maps: a method of obtaining a Boolean algebra expression from a truth table
involving the

Benefits of using Karnaugh maps:

● Minimizes the number of boolean expressions


22

● Minimizes the number of logic gates used, thus providing more efficient circuit

In the maps, the column is the last input while the row is the rest, for example:
A B C, C would be the column, AB would be the row
A B, B would be the column A would be the row

Rules of simplifying a K-map (this is NOT a question, just a summary of rules):

● No zeros allowed
● No diagonal
● Only power of 2 number of cells in each group
● Groups should be as large as possible
● Every one must be in at least one group
● Overlapping allowed
● Wrap around allowed
● Fewest number of groups possible

16. System Software

Purpose of an operating system (OS) (Refer to these explanations of the function of the
OS only if its not in the rest of the notes for this chapter):

● Optimizes the use of computer resources by implementing process scheduling to


ensure efficient CPU use, manages main memory usage, Optimizes I/O (Dictates
whether I/O passes through CPU or not)
● Hides the complexities of the hardware, UI allows users to interact with
application programs, automatically provides drivers for new devices, provides file
system (Organize physical storage of files on disk), provides a programming
23

environment, removing the need of processor functions, and provides system calls
(portability)
● Multitasking, More than one program can be stored in memory, but only one can
have CPU access at any given time. The rest of the programs remain ready
● Process: A program being executed which has an associated Process Control Block
(PCB) in memory, a PCB is a complex data structure containing all relevant data to
the execution of a process, process stats include; Ready (A new process arrives at
the memory, and the PCB is created). Running (Has CPU access). Blocked (Cannot
progress until some event has occurred)
● Scheduling ensures the computer system can serve all requests and obtain a
certain quality of service
● Interrupt causes OS kernel to invoke ISR, which means the kernel may have to
decide on a priority and register values stored in PCB, reasons for an interrupt
could be errors, waiting for I/O, scheduling halts process
● Low-level scheduling: Allocation of specific processor components to complete
specific tasks, OS contains low-level scheduling algorithms
● Preemptive: Will stop the process that would have otherwise have continued to
execute normally
● First-come-first-served, Non-preemptive and FIFO queue
● Round-robin, allocates time slice to each process, preemptive, can be a FIFO
queue, does not prioritize
● Priority based, most complex as priorities re-evaluated on queue change, priority
calculator requires computation, criteria for priority time is estimated time of
execution, estimated remaining time of execution, is the CPU/IO bound? Length of
time spent in waiting queue
● Paging, process split into pages, memory split into frames, all pages loaded into
memory at once
● Virtual memory: No need for all pages to be in memory, CPU address space is thus
larger than physical space, addresses resolved by the memory management unit,
the process of virtual memory is as it goes: All pages on the disk initially, one/more
loaded into memory when process ‘ready’, pages replaced from disk when needed
(this can be done with FIFO queue or usage-statistics-based algorithm)
● Disk thrashing: Perpetual loading/unloading of pages due to a page from disk
immediately requiring the page it replaced.
24

An OS has to be structured to provide a platform for resource management and facilities


for users. The logical structure provides 2 modes of operation:

● The user mode is the one available for the user or an application program.
● Privileged/kernel mode has the sole access to parts of the memory and to certain
system functions that the user mode can’t access.

Lexical analysis: The process of converting a sequence of characters to a sequence of


tokens
Tokens: Strings with an assigned meaning

Syntax analysis: Using parsing algorithms to interpret the meaning of sequence of tokens
and check the grammar

Code generation: The process by which an intermediate code is generated after syntax
analysis
25

Optimization: A process in which the code is edited to make efficiency improvements.


(Minimizing a program’s execution time and memory requirement)

For interpreters:

● Analysis and code generation run for each code line as above
● Each line is executed as soon as the intermediate code is generated

Outline the purpose of syntax analysis:

● It checks that the code matches the grammar of the language // checks the tokens
conform with the rules of the programming language
● Syntax errors are reported
● A parse tree is produced

Explain what is meant by virtual memory:

● Disk / secondary storage is used to extend the RAM so the CPU appears to be able
to access more memory space than the available RAM
● Only the data in use needs to be in main memory so data can be swapped
between RAM and virtual memory as necessary
● Virtual memory is created temporary
26

State the difference between paging and segmentation in the way memory is divided:

● Paging allows the memory to be divided into fixed sized blocks and segmentation
divides the memory into variable sized blocks
● The operating system divides the memory into pages, the compiler is responsible
for calculating the segment size
● Access times for paging is faster than for segmentation

State uses of a stack:

● Recursion
● Implementation of ADT
● Procedure calls
● Interrupt handling
● RPN

Explain why Reverse Polish Notation (RPN) is used to carry out the evaluation of
expressions

● RPN provides an unambiguous method of representing an expression reading from


left to right without the need to use brackets and with no need for rules of
procedures

Identify, with reasons a data structure that could be used to evaluate an expression in
RPN

● Stack: The operands are popped from the stack in the reverse order to how they
were pushed
● Binary tree: A tree allows both infix and postfix to be evaluated (tree inversal)

Explain how an interpreter executes a program without producing a complete translated


version of it:

● An interpreter examines source code one statement at a time


● Check statement for errors, if no error is found the statement is executed, if an
error is found this is reported and interpreter halts
● Interpretation is repeated for every iteration in repeated sections of code
● Interpretation has to be repeated every time the program is run

BNF is a formal mathematical way of defining syntax unambiguously, it consists of a set


of terminal symbols, a set of non-terminal symbols, a set of production rules
27

LHS ::= RHS (Left hand side (always non terminal symbol) is defined by the right hand
side (sequence of symbols (terminal or non terminal)))

Some examples we can take is:

● <DIGIT> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 (| means OR)


● <LETTER> ::= A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | … | X | Y | Z|
● <WORD> ::= <LETTER> | <LETTER><WORD> (recursion is possible, so this means
<WORD> can be a letter OR a letter and a word, in another way word is now any
number of letters)

These can also be represented in syntax diagrams like this:


28

The password “sentence" you see at the bottom is how it can be formed, and must follow
that order, for example a password produced from this like F$4 would be invalid as the
order must be a letter → digit → symbol, and the loop indicates that it can be repeated
like ASD55$$, anything used that is not in the diagram would count as an invalid letter
and therefore make the password invalid for example ? is not a valid symbol so it would
make the password invalid

Reverse Polish notation (RPN): A method of representing an arithmetic or logical


expression without brackets or special punctuation. RPN uses postfix notation, where an
operator is placed after the variables it acts on. For example, A + B would be written as A
B+
Compilers use RPN because any expression can be processed from left to right without
backtracking.

Advantages of RPN:

● RPN expressions do not need brackets, and there is no need for the precedence of
operators
● RPN is simpler for a machine to evaluate
● There is no need for backtracking in evaluation as the operators appear in the
order required for computation and can be evaluated from left to right

Expressing a * b + b - d + 15 in RPN would give:


a b * b + d - 15 +
29

Expressing a b - c d + * a / in infix form would give:


(a - b) * (c - d) / a

The process is done step by step where the most recent process is on top (RPN can also
be done in binary trees)

17. Security

Plain text: Data before encryption

Cipher text: The result of applying an encryption algorithm to data.

Encryption: The making of cipher text from plain text, encryption can be used when
transmitting data over a network, it is a routine procedure when storing data within a
computing system

State what is meant by a private key:

● A private key is the unpublished key


● It has a matching public key
● It is used to decrypt data that was encrypted with its matching public key
30

State what is meant by a public key:

● Key widely available that can be used to encrypt message that only owner of
private key can decrypt

Explain the differences between symmetric and asymmetric cryptography when


encrypting.

● Symmetric cryptography uses a single key to encrypt and decrypt messages,


Asymmetric cryptography uses two.
● The symmetric key is shared, whereas with asymmetric, only the public key is
shared (and the private key isn’t).
● the risk of compromise is higher with symmetric encryption and asymmetric
encryption is more secure.
● Symmetric cryptography is a simple process that can be carried out quickly, but
asymmetric is much more complex, so slower.
● The length of the keys in symmetric encryption are (usually) shorter than those for
asymmetric (128/256 bits v 2048 bits).

Similarities between public and private key:

● Both used in asymmetric encryption, as a pair of keys is required


● One is used to decrypt the message and the other is used to decrypt it
● Both hashing algorithms

Differences between public and private key:

● Private key only known to owner of the key pair, the public key can be distributed
to anyone
● When the messages are sent to the owner of a public key, they are encrypted with
the owners public key so they can only be decrypted with owners private key
● Message digests are encrypted with the private key of the sender to form a digital
signature
● Messages are encrypted with the public key of the receiver

Describe the process of asymmetric encryption:

● The message to be sent is encrypted using the recipient’s/sender’s public key


● The message is decrypted using the recipient’s/sender’s private key

Explain how a digital signature is used to verify a message when it is received:


31

● The message that came with the digital signature is decrypted using the receiver’s
private key
● The digital signature received is decrypted with the sender’s public key to recover
the message digest sent
● The decrypted message received is hashed with the agreed hashing algorithm to
reproduce the message digest of the messages received
● The two messages digests are compared, if both digests are the same the
message has not been altered

Similarities between digital certificate and digital signature:

● Both used for authentication


● Both are unique to the owner
● Includes owner’s public key
● Includes hashing algorithm

Differences between digital certificate and digital signature:

● Certificate obtained from issuing authority, signature created from a message


● Certificate provides authentication of owner while signatures used to authenticate
messages that are sent by the owner
● Certificate remain unchanged while a new signature is created for each message
● Only certificate provides extra information
● Only signature makes use of a private key

State differences between symmetric and asymmetric encryption:

● Symmetric encryption uses a single key and asymmetric encryption uses a pair of
keys.
● The symmetric single key is used by all, whereas only one of the keys for
asymmetric encryption is available to everyone / one of the asymmetric encryption
keys needs to be kept secret.

State how a digital certificate is obtained:

● Enquiry made to certificate authority (CA)


● Enquirer’s details checked by CA
● If enquirer details verified then public key is agreed
● CA creates certificate that includes enquirer’s public key
● Encrypting data sent to/by CA with the CA’s public/private key
32

Give reasons for using key cryptography:

● To ensure the message is authentic


● To ensure that only the intended receiver is able to understand the message
● To ensure the message has not been altered during transmission

State possible benefits of using quantum cryptography:

● Any eavesdropping can be identified as the state will be changed


● Integrity of the key once transferred can be guaranteed (cannot be copied and
decrypted in a later date)
● Longer/more secure keys can be exchanged

State possible drawbacks of using quantum cryptography:

● Limited range
● Required dedicated fiber (optic) line and specialist hardware
● Cost of dedicated fiber (optic) line and specialist hardware is expensive
● Polarization of light may be altered whilst traveling down fiber optic cables

Describe the purpose of Secure Sockets Layer (SSL) and Transport Layer Security (TLS)
protocols:

● The SSL and TLS protocols provide communication security over the internet, as
they provide encryption
● They enable two parties to identify and authenticate each other and communicate
with confidentiality and integrity

Explain how SSL/TLS protocols are used when a client-server communication is initiated:

● An SSL/TLS connection is initiated by an application which becomes the client


● The application which receives the connection becomes the server
● Every new session begins with a handshake (as defined by the SSL/TLS protocols)
● The client requests the digital certificate from the server
● The client verifies the server’s digital certificate and obtains the server’s public key
● The encryption algorithms are agreed
● The symmetric session keys are generated
33

Virus: tries to replicate inside other executable programs.

Worm: runs independently and propagates to other network hosts.

Spyware: collects info & transmits to another system.

Phishing: email from seemingly legit source requesting confidential info.

Pharming: setting up a bogus website that appears to be legit.

Malware Vulnerabilities exploited Methods of restriction

Virus Executable files used to run Install and use an


or install software. Anti-Virus software that
runs daily scans.

Worm Shared networks Set up a firewall to protect


yourself from external
networks.

Spyware Background processes Install and use real-time


Anti-Spyware protection.

Phishing Users mindset on Always check the sender’s


considering emails from email address.
random addresses to be
trustworthy

Pharming Users’ mindset of relying Always double-check the


on the website’s user website name.
interface rather than the
URL for its validity.
34

18. Artificial Intelligence

Reinforcement learning: Enables learning in an interactive environment by trial and error


using its own experiences

Artificial Intelligence is the ability of computers to perform tasks that usually only a
human would be able to do, such as decision-making, speech recognition, etc.

Describe the purpose of both the A* algorithm and Dijkstra’s algorithm:

● To find the optimal / shortest / most cost-effective route between two nodes based
on distance / cost / time

Machine learning (ML) is a subfield of artificial intelligence where computers learn to


perform tasks without being explicitly programmed. Machine learning computers are fed
with historical training data, which produces a model from which predictions about
previously unseen data can be made.

Machine Learning (ML) Deep Learning (DL)

Allows machines to make decisions Allows machines to make decisions using


independently based on past data ANN (Artificial Neural Networks)

A small amount of data is required at the Large amount of data is required at the
training stage training stage

Most of the data’s feature must be Deep learning does not require advanced
identified beforehand and manually coded identification of data features as it learns
into the system them from the data itself

A given task is solved using a modular The problem is solved from beginning to
approach where each module is then end as a single entity
combined to create a final model

Testing of the system takes a long time Testing of the system takes less time

There are specific rules that clarify the The system makes decisions based on its
reasoning behind every step in the model own logic, making the reasoning behind
those decisions difficult to understand

Labeled and Unlabeled data: Labeled data is fully defined and recognisable. Unlabelled
data is data which is unidentified and unrecognizable.
35

Describe what is meant by supervised learning:

● Supervised learning allows data to be collected, or a data output produced, from


the previous experience
● In supervised learning, known input and associated outputs are given
● Able to predict future outcomes based on past data

Describe what is meant by unsupervised learning:

● Unsupervised machine learning helps all kinds of unknown patterns in data to be


found
● Unsupervised learning only requires input data to be given
● Uses any data

Describe what is meant by deep learning:

● Uses artificial neural networks that contains a high number of hidden layers
modeled on the human brain
● Deep learning uses many layers to progressively extract high level features from
the raw input
● Deep learning is a specialized form of machine learning

Outline the reasons for using deep learning:

● Deep learning makes good use of unstructured data.


● Deep learning outperforms other methods if the data size is large.
● Deep learning systems enable machines to process data with a nonlinear
approach.
● Deep learning is effective at identifying (hidden) patterns / patterns that humans
might not be able to see / patterns that are too complex / time consuming for
humans to carry out.
● It can provide a more accurate outcome with higher numbers of hidden layers.

State the reason for having multiple hidden layers in an artificial neural network:

● Enables deep learning to take place


● Where the problem you are trying to solve has a higher level of complexity it
requires more layers to solve
● To enable the neural network to learn and make decisions on its own
36

● To improve the accuracy of the result

Explain how artificial neural networks enable machine learning:

● Artificial neural networks are intended to replicate the way human brains work
● Weights / values are assigned for each connection between nodes
● The data are input at the input layer and are passed into the system They are
analyzed at each subsequent (hidden) layer where characteristics are extracted /
outputs are calculated
● this process of training / learning is repeated many times to achieve optimum
outputs // reinforcement learning takes place
● Decisions can be made without being specifically programmed
● The deep learning net will have created complex feature detectors The output
layer provides the results
● Back propagation (of errors) will be used to correct any errors that have been
made.

Explain the use of graphs to aid Artificial Intelligence (AI):

● Artificial Neural Networks can be represented using graphs


● Graphs provide structures for relationships
● AI problems can be defined/solved as finding a path in a graph
● Graphs may be analyzed by a range of algorithms for example A*/Dijkstara’s
algorithm used in machine learning
● Allows for usage regression methods / back propagation of errors

Classification: Split the data into two or more predefined groups. Example: spam email
filtering, where emails are split into either spam or not

Regression: It is a supervised machine-learning technique that predicts the value of a


dependent variable based on another explanatory variable
Regression models can be used for weather forecasting, predicting health-care trends,
financial forecasting, sales prediction and so on

Linear Regression: They are used where there is a straight-line correlation between
variables
37

Non-Linear Regression: Used where there is a correlation but it is not linear

Clustering: Split the data into smaller groups or clusters based on specific features. The
programmer might specify a target number of groups or let the algorithm decide.

Back Propagation method:

● The results generated by the systems are compared to the expected outcome.
● The difference between the two results is calculated.
38

● Outputs travel back from the output layer to the hidden layer to adjust the initial
weightings on each neuron.
● ErrorB= Actual Output – Desired Output
● If the error difference is too large, the weightings are altered.
● The process is iterative until the outputs have an acceptable error range or until
the weights stop changing. The model has then been successfully set up.
● https://www.youtube.com/watch?v=Ilg3gGewQ5U Good explanation

Components of a graph:

● Nodes are the fundamental units of the graph. Every node can be labeled or
unlabelled.
● Edges: Edges are lines used to connect two nodes of the graph. It can be an
ordered pair of nodes in a directed graph. Every edge can be labeled/unlabelled.
● The graph below has a set of nodes V= { 1,2,3,4,5} and a set of edges E= {
(1,2),(1,3),(2,3),(2,4),(2,5),(3,5),(4,50 }.

Some terminologies you might need to know:

● Adjacency: 2 nodes are said to be adjacent if they are endpoints of the same edge.
● Path: A set of alternating nodes and edges allows you to go from one node to
another. A path with unique nodes is called a simple path.

Now let us take this graph to explain Dijkstra’s algorithm


39

We want to calculate the shortest distance for each town, so how do we go about that?
There are many ways to get to town 1, however the smallest value to reach there is 3,
that means it is the shortest distance so take it as 3, town 2 only has 1 way from base so
we simply take it as 5, town 3 also has many ways but the shortest value/distance is 2, so
we just keep repeating until we find shortest distance to each town.

https://www.youtube.com/watch?v=pVfj6mxhdMw (Dijkstar’s Algorithm)

There are limitation to this algorithm however:

● A lack of heuristics: Dijkstra’s algorithm has no notion of the overall shortest


direction to the end goal, so it will spend a lot of time searching in completely the
wrong direction if the routes in the wrong direction are shorter than the route in
the correct direction. It will find the shortest route but waste a lot of time. Now
40

this would not be a problem in small networks, but in large networks it will result
in massive inefficiencies
● Negative weighted costs: On physical networks with physical distances, you can’t
have negative weights, but on some networks where you calculate costs, you
might have negative costs for a particular leg. Dijkstra can’t handle these negative
costs
● Directed networks: Dijkstra’s algorithm doesn’t always work best when there are
directed networks (such as motorways that only run in one direction)

A* Algorithm:

● A* is an informed search algorithm, or a best-first search, meaning that it is


formulated in terms of weighted graphs: starting from a specific starting node of a
graph, it aims to find a path using a heuristic value, which gives priority to nodes
that are supposed to be better than others, to the given goal node having the
smallest cost (least distance traveled, shortest time, etc.). It maintains a tree of
paths originating at the start node and extends those paths one edge at a time
until its termination criterion is satisfied.
● At each iteration of its main loop, A* must determine which paths to extend. It
does so based on the path's cost and an estimate of the cost required to extend
the path to the goal.

Let us solve an example down below, h being heuristic value, g being the movement cost,
and f being the total of g and h:

Now we want to find the shortest path between the home and school nodes using A*
algorithm,
41

Start from the Home. The cost from Home to Home is 0, so g= 0. The heuristic cost of a
home is 14, so h=14 and f=g+h=14

Now, there are three immediate nodes from home: A, B, and C. Calculate the values of g, h
and f for A, B and C from home and write them in the table

Select the node whose f value is the shortest (in this case, Node A)

From A, there are two immediate nodes, B and E. Calculate the g value for each node and
add the g value of A. Then, add the corresponding h values to get f for each node. Then
go to the node with whose f value is shortest again (in this case, Node E)

From E, there are two immediate nodes, School and F. Calculate the g value for each node
and add the g value of E. Then, add the corresponding h values to get f for each node

From F to School, add the g value (3) to the g value of F (8) and calculate f

So the final path would be Home → A → E → F → School

https://www.youtube.com/watch?v=6TsL96NAZCo (A* Algorithm)

TABLE IS BELOW

Node Cost from Home Node (g) Heuristic (h) Total (f = g + h)

1 Home 0 14 14

2 A 1 10 11

3 B 5 7 12

4 C 4 9 13

5 B 1+3=4 7 11

6 E 1+6=7 3 10

7 F 7+1=8 3 11

8 School 7+5=12 0 12

9 School 1+6+1+3=11 0 11
42

You might also like