Professional Documents
Culture Documents
2023 CSC 0795 Mark Guide
2023 CSC 0795 Mark Guide
GCE PAPER 3
Mark Guide
SECTION A: A Plotting Program (Program Development)
Describing the Task.
Many interesting programming problems involving nested loops can be encountered when creating plots using printera.
Your task is to create the plot of a pyramid in a general manner with the size of the base entered at the begining of progrm
execution. Arrays are not used to do this. A pyramid has a number of stars at its base (MaxNoOfStars) and is made up
of spaces and stars. Each line of the pyramid is made up of an odd number of leading spaces (NoOfSpaces} followed by a
number of stars (NoOfStars). There are blanks after the stars, but they are not important for this exercise.
Task 1: Problem Understanding
1.
(i) The initial maximum number of stars is calculated based on the size of the base entered by the user and is
calculated using the formula `2 * base size - 1`. This formula takes the size of the base and calculates the
maximum number of stars that will be present in the bottom row of the pyramid. For example, if the user enters
a base size of 5, then the maximum number of stars in the bottom row will be `2 * 5 - 1 = 9`. This means that
the pyramid will have a base row with 9 stars, and each row above it will have 2 fewer stars than the row below
it until there is only 1 star at the top of the pyramid. Hence the initial values are 6,5,4,3,2, and1.
(ii) Leading Space (NoOfSpace) for the first line = 5
Stars (NoOfStars) = 1
(iii) Leading Space (NoOfSpace) for the second line = 4
Stars (NoOfStars) = 3
(iv) To print successive rows from the top of the pyramid, you would need to modify `NoOfSpaces` and
`NoOfStars` by the following amounts before printing each subsequent line:
- `NoOfSpaces` should be increased by 1, since the number of leading spaces increases by 1 between
successive lines.
- `NoOfStars` should be decreased by 2, since the number of stars decreases by 2 between successive lines.
#include <stdio.h>
int main() {
int base_size, max_no_of_stars, no_of_stars, no_of_spaces, i, j;
return 0;
}
3. Write an Algorithm given as pseudocode above as a main program that calls the procedures (or functions) you
implemented above. For it, the NoOfSpaces, NoOfStars and MaxNoOfStars, presented under Task Description are
stored in global variables. [Hint: The condition "number of stars is the number required" in the algorithm could be
coded as "NoOfStars>MaxNoOfStars".]
#include <stdio.h>
int NoOfSpaces, NoOfStars, MaxNoOfStars;
void printSpaces() {
for (int i = 0; i < NoOfSpaces; i++) {
printf(" ");
}
}
void printStars() {
for (int i = 0; i < NoOfStars; i++) {
printf("*");
}
}
int main() {
printf("Enter the size of the base of the pyramid: ");
scanf("%d", &MaxNoOfStars);
NoOfSpaces = (MaxNoOfStars - 1) / 2;
NoOfStars = 1;
while (NoOfStars <= MaxNoOfStars) {
printSpaces();
printStars();
printf("\n");
NoOfStars += 2;
NoOfSpaces--;
}
return 0;
}
Task3
4. (i)
(ii)
#include <stdio.h>
int main() {
int base_size, max_no_of_stars, no_of_stars, no_of_spaces, i, j;
printf("Enter the size of the base of the pyramid: ");
scanf("%d", &base_size);
// Calculate the maximum number of stars in the base
max_no_of_stars = 2 * base_size - 1;
// Loop through each row of the pyramid
for (i = 1; i <= base_size; i++) {
// Calculate the number of stars and spaces for this row
no_of_stars = 2 * i - 1;
no_of_spaces = (max_no_of_stars - no_of_stars) / 2;
// Print the spaces and stars for this row
for (j = 1; j <= no_of_spaces; j++) {
printf(" ");
}
for (j = 1; j <= no_of_stars; j++) {
printf("*");
}
printf("\n");
}
return 0;
}
Task4.
(i)
StartDate
TeacherID
PupilID
TripID PupilSurName
FirstName
1 1,n n
n
TeacherID , Supervises Trip Attends Pupil
USE TripsDB;
(b) Populate the TRIP relation of your database with 3-5 rows of trip data. The data for each trip should be consistent
with data for the TEACHER relation.
(d) Populate the relation PUPILTRIP such that its data is consistent with the relations PUPIL and TRIP relation.
(iv) Using SQL commands, write an SQL statement to query the database tables for each of the following:
(a) The TripID, StartDate, EndDATE AND Destination of all trips supervised by the teacher with teacherid T1
-- Selecting StartDate, EndDate and Destination of all trips supervised by the teacher with TeacherID T1
SELECT StartDate, EndDate, Destination
FROM TRIP
WHERE TeacherID = 'T1';
(b) The TripID and the name of pupil who attended a trip supervised by the teacher with TeacherID T1
Therefore, we would need 13 CDs (rounded up from 12.43) with a capacity of 700MB each to store information in
a full double-sided DVD.
(ii) To build a circuit that can add two 4-bit numbers, we can use a combination of full adders and half adders.
(a) Explain the difference between Full Adder and Half Adder
A half adder can only add two 1-bit numbers and produce a 2-bit output, consisting of a sum bit (S) and a
carry bit (C). The half adder does not take into account any carry bit from previous additions.
A full adder, on the other hand, can add three 1-bit numbers: two input bits and a carry bit from a previous
addition. Like the half adder, the full adder produces a sum bit (S) and a carry bit (C).
However, the carry bit from the full adder can be used as an input to another full adder, allowing for addition
of multiple bits.
(b) Draw a block diagram of your circuit which shows how the numbers 1011and 1110are being added. show and label
all inputs and outputs. use at least one half-adder and at least one full-adder.
(iii) Characteristics of a CPU that affects the overall performance of a computer?
There are several characteristics of a CPU (Central Processing Unit) that can affect the overall performance of a
computer:
1. Clock speed: The clock speed of a CPU determines how many instructions it can execute in a given amount of
time. Higher clock speeds generally result in faster processing times.
2. Number of cores: CPUs can have multiple cores, which allows them to perform multiple tasks simultaneously.
More cores generally result in better multitasking performance.
3. Cache size: CPUs have a cache, which is a small amount of memory used to store frequently accessed data. A
larger cache can improve performance by reducing the need to access main memory. Thus, the larger the cache size
the better the performance.
4. Instruction set architecture (ISA): The ISA determines the types of instructions that a CPU can execute. CPUs
with more advanced ISAs can perform more complex operations, which can improve performance for certain types
of applications.
5. Thermal design power (TDP): The TDP is a measure of how much power a CPU consumes and how much
heat it generates. CPUs with higher TDPs may require more cooling and can affect the overall power consumption
and noise level of a computer.
6. Overclocking capability: Overclocking is the process of increasing the clock speed of a CPU beyond its rated
speed. CPUs with better overclocking capability can potentially achieve higher performance, but may also require
better cooling and can void warranty.
7. Data bus width: the larger the data bus width the better the performance.
(ii) (a)
𝑃𝑟𝑜𝑐𝑒𝑠𝑠𝑜𝑟 𝑤𝑜𝑟𝑑 𝑙𝑒𝑛𝑔𝑡ℎ = 32 𝑏𝑖𝑡𝑠
𝑆𝑖𝑛𝑐𝑒 𝑎𝑛 𝑖𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛 = 32 𝑏𝑖𝑡𝑠 𝑙𝑜𝑛𝑔,
32
If there is equal distribution of bits between Opcode field and Operand field, then each field will be assigned 4 = 8𝑏𝑖𝑡𝑠
Thus possible minimum for Opcode = 𝟒 𝒃𝒊𝒕𝒔
(b) 𝑀𝑖𝑛𝑖𝑚𝑢𝑚 𝑏𝑖𝑡𝑠 𝑓𝑜𝑟 𝑟𝑒𝑔𝑖𝑠𝑡𝑒𝑟𝑠 = 8 𝑏𝑖𝑡𝑠 𝑒𝑎𝑐ℎ
(c) Based on minimum for Ocode and Registers above,
𝑀𝑎𝑥𝑖𝑚𝑢𝑚 𝑓𝑜𝑟 𝑖𝑚𝑚𝑒𝑑𝑖𝑎𝑡𝑒 𝑜𝑝𝑒𝑟𝑎𝑛𝑑 = 32 − 20 = 𝟏𝟐𝒃𝒊𝒕𝒔
(d) – It has fewer instruction formats
- It uses fewer addressing modes
- It makes use of single cycle instructions
- It executes instructions faster
(iii)
(a) SISD = Single Instruction Single Data
(b) Block Diagram
1. Memory allocation: Paging divides physical memory into fixed-size blocks called pages, while segmentation
divides logical memory into variable-sized blocks called segments.
2. Addressing: In paging, memory addresses are divided into a page number and an offset within the page. In
segmentation, memory addresses are divided into a segment number and an offset within the segment.
3. Fragmentation: Paging can lead to internal fragmentation, where some space within a page may be unused.
Segmentation can lead to external fragmentation, where there may be unused space between segments.
4. Protection: Paging provides protection by assigning each page a protection level. Segmentation provides
protection by assigning each segment a protection level.
5. Implementation: Paging is simpler to implement than segmentation since it only requires dividing memory into
fixed-size pages. Segmentation is more complex to implement since it requires managing variable-sized segments
of memory.
6. Performance: Paging can result in more page faults, which can affect performance. Segmentation can result in
better performance for certain types of programs since it allows for more efficient use of memory.
Overall, paging and segmentation are useful memory management techniques that have different advantages and
disadvantages. Paging is simpler to implement but can lead to internal fragmentation, while segmentation is more
complex but allows for more efficient use of memory.
(b) the operating system provides an interface between the hardware and the software running on the computer.
the operating system manages the computer's hardware resources, such as the CPU, memory, and I/O devices,
and provides a layer of abstraction that shields software applications from the underlying hardware complexity.
The operating system also provides a set of standard APIs (Application Programming Interfaces) that software
applications can use to interact with the hardware, making it easier to develop software that can run on
different systems.
(c) Real-time processing and batch processing are two different methods of processing data.
Real-time processing involves processing data as soon as it is received, without any delay. This method is used in
situations where immediate action is required based on the data received. For example, in a stock trading
application, real-time processing is used to process stock prices and make trades in real-time. Another example is in
online gaming, where real-time processing is used to process player actions and update the game state in real-time.
Batch processing, on the other hand, involves processing data in batches, usually at a scheduled time or when a
certain amount of data has accumulated. This method is used when immediate action is not required, and the data
can be processed at a later time. For example, in a payroll system, batch processing is used to process employee
salaries at the end of each pay period. Another example is in a billing system, where batch processing is used to
generate invoices at the end of each billing cycle.
In summary, real-time processing is used when immediate action is required based on the data received, while
batch processing is used when immediate action is not required, and the data can be processed at a later time.
(ii)(a) Gantt chart
(b)
Process AT ST CT TAT WT
P1 0 7 16 16 9
P2 2 4 7 5 1
P3 4 1 5 1 0
P4 5 4 11 6 2
16+5+1+6 28
Average Turnaround time = =
4 4
= 𝟕 𝒕𝒊𝒎𝒆 𝒖𝒏𝒊𝒕𝒔
9+1+0+2 12
Average Waiting time = =
4 4
= 𝟑 𝒕𝒊𝒎𝒆 𝒖𝒏𝒊𝒕𝒔
(c)
𝑁𝑜 𝑜𝑓 𝑝𝑟𝑜𝑐𝑒𝑠𝑠𝑒𝑠
𝑇ℎ𝑟𝑜𝑢𝑔ℎ𝑝𝑢𝑡 =
𝑇𝑜𝑡𝑎𝑙 𝑠𝑐ℎ𝑒𝑑𝑢𝑙𝑒 𝑡𝑖𝑚𝑒
1
𝑂𝑅 𝑁𝑜 𝑜𝑓 𝑝𝑟𝑜𝑐𝑒𝑠𝑠𝑒𝑠
4 1
𝑇ℎ𝑟𝑜𝑢𝑔ℎ𝑝𝑢𝑡 = = = 𝟎. 𝟐𝟓 𝒑𝒓𝒐𝒄𝒆𝒔𝒔𝒆𝒔 𝒑𝒆𝒓 𝒖𝒏𝒊𝒕 𝒕𝒊𝒎𝒆
16 4
4.(i) (a) A computer network is an interconnection of devices using communication links for the purpose of sharing
resources.
(b) Advantages
- File sharing: networks provide a rapid method for sharing and transferring files.
- Resource sharing: networks enable limited or expensive resources such as printers, scanners, copies or software to be used
by all configured devices in the network for which access is allowed.
- Increase storage capacity: it enables files and multimedia (such as images, audio, video) to be stored and accessed
remotely on other machines or network attached storage.
- Data is easy to backup since it stored in a file server.
Disadvantages
- Cost: the initial cost of setting up a network may be high.
- Liable to malware: Malware like viruses can spread to other computers throughout the network easily.
- Security: computers in a network are liable to dangers like hacking especially if they’re no protected with a firewall.
- Server Failure: if the server breaks down, files and data will be in accessible.
(b) - Band width: the choice of cable should have a band width that provides the best band width desired for the
application.
- Transmission rate: the choice of cable should provide high data transmission rate as desired.
- Effect of transmission impairments: the choice of cable should be one less affected by transmission impairments like
attenuation, interference, distortion.
- Ease of installation: the choice of cabling should be one which can be installed within reasonable time and for which there
exist skilled personnel to set it up.
(c) Microwave (also: Satellite, Infrared, RFID(radio-frequency identification), Bluetooth, Free Space Optics) : it makes use
of electromagnetic(EM) waves to transmit signals between devices.
(d) Advantage
- Wireless networks are easier and faster to setup.
- Devices within range can easily be added to the network.
- Wireless networks can be accessed while moving around with your devices without being disconnected.
- They can be extended to places where cables cannot be accessed.
Disadvantage
- Wireless networks are more exposed to attacks by unauthorized users.
- Signal interruptions: interference may be experienced if other people also use wireless technology or other sources
emitting EM waves.
- Wireless transmission is relatively slower
- They have limited band width
5.(i)(a) Anomalies
- Insertion Anomaly: it occurs when the insertion of a new data record is not possible unless additional unrelated data is
added to the record.
Example: inserting a student record in a table containing student and course information is impossible unless course data is
provided.
- Deletion Anomaly: it occurs when the deletion of a data record leads to the deletion of unrelated data that was stored as
part of the record.
Example: deleting a student record in a table containing student and course information may lead to deletion of information
about a course.
Update Anomaly: it occurs when data that exist in many fields is updated in some but not all fields containing the same
data.
Example: if a student’s age is changed from 25 to 16 in one field but not in other fields for the same student, the student age
becomes inconsistent.
(ii)(a)
- Primary Key: it is an attribute or group of attributes that can uniquely identify records in a table e.g Stud_ID or Trip_ID.
- Composite key: It is a collection of two or more attributes which are minimal. E.g (Stud_ID, Trip_ID)
- Associative table: A table that maps two or more tables together by referencing their primary keys e.g PAYMENT.
.
(b) Many to Many (M:N) relationship. A student can attend many trips and a trip can be attended by many students.
6. (i) (a)
- Infix: a way of representing arithmetic operations in which operators are placed in between operands.
- Prefix: here operators precede operands.
- Postfix: Here operators are placed after their operands.
(c)
- Pre-Test Loop: For or While loop
- Post-Test Loop: Do-while (Repeat-Until) loop.
(c) Parameters are the variables declared in a functions parameter list, when it is declared or defined, whereas arguments
are the values passed to a function when it is called.
8.(i)
- Determining the type of data and data transformation procedures needed.
- Decide on the type of tools (software & Hardware) to use.
- Build a model/template of the new/existing system.
- Proposition of alternative solutions.
- Quality verification and validation.
- Planning and assessment for security risk.
(ii) This can occur if components pass the unit test but when integrated together do not interface correctly with each other,
and therefore fails to run. Integration testing fails.
(iii) (a)
- Immediate change: Applicable in small organizations which do not carry out critical operations.
- Running in Parallel: Applicable for organisations that run critical (high risk) operations that are similar for both the old
and new system.
- Gradual Introduction of New system: Applicable in Organisations that run clearly distinct operations in different
departments.
(iv)(a)
- Black box testing: here, the functioning of the system is tested without any knowledge of the internal working of the
system.
- White box testing: here, the internal structure or working of a program/system is verified, requiring coding or technical
skills.