Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

2023 CSC 0795

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;

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;
}

Task2: Program Development

Write the following functions and/or procedures.


(i) The procedure Initialise (MaxNoOfStars, NoOfSpaces, NoOfStars) to initialize the variables
MaxNoOfStars, NoOfSpaces and NoOfStars for the first line.
procedure Initialise (var MaxNoOfStars, NoOfSpaces, NoOfStars: integer);
begin
MaxNoOfStars := 10;
NoOfSpaces :=
MaxNoOfStars div 2;
NoOfStars := 1;
end;
(ii) The procedure OutputLeadingSpaces(nSpaces) which takes the number nSpaces and outputs that number
of leading spaces for a line on the screen.
procedure OutputLeadingSpaces(nSpaces: integer);
var
i: integer;
begin
for i := 1 to nSpaces do
write(' ');
end;
(iii) The procedure OutputLineOfStars (nStars) which takes the number nStars and outputs that number of stars
for a line on the screen.
Procedure OutputLineOfStars(nStars: integer);
var
i: integer;
begin
for i := 1 to nStars do
write('*');
end;
(iv) The procedure Adjust (NoOfSpaces, NoOfStars) adjusts the variables NoOfSpaces and NoOfStars to the
values used to print the next row of blanks and stars.
Procedure Adjust(var NoOfSpaces, NoOfStars: integer);
begin
Dec(NoOfSpaces);
Inc(NoOfStars, 2);
end;

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)

(ii) See above screenshot.


SECTION B: School Trip (Database)
A school keeps records of school trips, teachers who supervise these trips and pupil who attend trips in a database in a way
that will allow information about these details to be extracted. The data requirements are defined as follows:
• Each trip is assigned a trip id (unique), start date, end date and destination.
• Each teacher has a teacher id (unique), a title, first name and surname.
• Each pupil has an id (unique), first name, and a surname.
• Each pupil may attend more than one trip
• A trip can be attended by more than one pupil.
• Each trip is supervised by only one teacher at any given time.
• A teacher can supervise more than one trip
The relational database has four tables TEACHER, TRIP, PUPIL, PUPILTRIP whose meaning are obvious, with attributes
(primary key is underlined) as follows:
TEACHER(TeacherID, Title, FirstName, Surname)
TRIP(TripID, StartDate, EndDate, Destination, TeacherID)
PUPIL(PupilID, PupilSurname, PupilFirstName)
PUPILTRIP(PupilID, TripID)
(i) Draw an Entity-Relationship diagram that shows entities, relationships and the degree of each relationship for the
school trip database.

StartDate
TeacherID
PupilID
TripID PupilSurName
FirstName

1 1,n n
n
TeacherID , Supervises Trip Attends Pupil

Title TeacherID PupilFirstName


SurName
EndDate
Destination
(ii) Using sql statements,
Create a database called TripsDB
In TripsDB, create all relations given above

CREATE DATABASE TripsDB;

USE TripsDB;

CREATE TABLE TEACHER (


TeacherID INT PRIMARY KEY,
Title VARCHAR(10),
FirstName VARCHAR(50),
Surname VARCHAR(50)
);
CREATE TABLE TRIP (
TripID INT PRIMARY KEY,
StartDate DATE,
EndDate DATE,
Destination VARCHAR(100),
TeacherID INT,
FOREIGN KEY (TeacherID) REFERENCES TEACHER(TeacherID)
);

CREATE TABLE PUPIL (


PupilID INT PRIMARY KEY,
PupilSurname VARCHAR(50),
PupilFirstName VARCHAR(50)
);

CREATE TABLE PUPILTRIP (


PupilID INT,
TripID INT,
PRIMARY KEY (PupilID, TripID),
FOREIGN KEY (PupilID) REFERENCES PUPIL(PupilID),
FOREIGN KEY (TripID) REFERENCES TRIP(TripID)
);
(iii) Using the SQL insert Command,

(a) Populate the TEACHER relation with the following


TEACHERID TITLE FIRSTNAME SURNAME
T1 Mr. John Book
T2 Mrs. Mbong Ngum
T3 Mr. Aminde Tom

-- Inserting data into TEACHER relation


INSERT INTO TEACHER (TeacherID, Title, FirstName, Surname)
VALUES ('T1', 'Mr.', 'John', 'Book'),
('T2', 'Mrs.', 'Mbong', 'Ngum'),
('T3', 'Mr.', 'Aminde', 'Tom');

(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.

-- Inserting data into TRIP relation


INSERT INTO TRIP (TripID, StartDate, EndDate, Destination, TeacherID)
VALUES (1, '2023-07-01', '2023-07-07', 'Yaounde', 'T1'),
(2, '2023-08-10', '2023-08-15', 'Buea', 'T1'),
(3, '2023-09-20', '2023-09-25', 'Bamenda', 'T2'),
(4, '2023-10-15', '2023-10-20', 'Kribi', 'T3');
(c) Populate the PUPIL relation with the following data
PupilID PupilFIRSTNAME PupilSURNAME
P001 Neba Ngu
P002 Samira Bih
P003 Amina Abu
-- Inserting data into PUPIL relation
INSERT INTO PUPIL (PupilID, PupilFirstName, PupilSurname)
VALUES ('P001', 'Neba', 'Ngu'),
('P002', 'Samira', 'Bih'),
('P003', 'Amina', 'Abu');

(d) Populate the relation PUPILTRIP such that its data is consistent with the relations PUPIL and TRIP relation.

-- Inserting data into PUPILTRIP relation


INSERT INTO PUPILTRIP (PupilID, TripID)
VALUES ('P001', 1),
('P002', 1),
('P003', 2),
('P001', 3),
('P002', 4);

(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

SELECT TRIP.TripID, PUPIL.PupilFirstName, PUPIL.PupilSurname


FROM TRIP
INNER JOIN PUPILTRIP ON TRIP.TripID = PUPILTRIP.TripID
INNER JOIN PUPIL ON PUPILTRIP.PupilID = PUPIL.PupilID
WHERE TRIP.TeacherID = 'T1';
2023 CSC 0795
GCE PAPER 2
Mark Guide
1. (a) which of direct access and sequential access takes a longer time.? Explain your answer. (3marks)
Sequential access generally takes longer than direct access. This is because in sequential access, data is accessed
in a linear fashion, starting from the beginning, and moving through the data one record at a time until the desired
record is found. In contrast, with direct access, data can be accessed immediately by specifying its location.
Therefore, direct access is generally faster and more efficient for accessing specific data, while sequential access
is better suited for processing data in a specific order.
(b) (i) A double sided DVD has a capacity of 8.5GB, How many CDs of 700MB Capacity are required to store
information in a full double sided DVD?
To calculate the number of CDs required to store information in a full double-sided DVD, we need to divide the
capacity of the DVD by the capacity of a single CD.
𝐷𝑉𝐷 𝑐𝑎𝑝𝑎𝑐𝑖𝑡𝑦 = 8.5𝐺𝐵 = 8.5 × 1024𝑀𝐵
𝑐𝑎𝑝𝑎𝑐𝑖𝑡𝑦 𝑜𝑓 𝑎 𝐶𝐷 = 700𝑀𝐵
8.5 × 1024
𝑁𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝐶𝐷𝑠 𝑛𝑒𝑒𝑑𝑒𝑑 = = 12.43
700
𝑇ℎ𝑢𝑠 𝑁𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝐶𝐷𝑠 𝑛𝑒𝑒𝑑𝑒𝑑 = 𝟏𝟑 𝑪𝒅𝒔

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.

2. (i) (a) Denary equivalent


01111010 = 26 + 25 + 24 + 23 + 21
= 64 + 32 + 16 + 8 + 2 = 𝟏𝟐𝟐

(b) 01111010 in hexadecimal


. Grouping in 4 bits we have 0111 = 7; 1010 = 𝐴
𝑇ℎ𝑢𝑠 01111010 = 𝟕𝑨𝟏𝟔
(c)
01111010
+ 01111010
111101002
𝐷𝑒𝑐𝑖𝑚𝑎𝑙 𝐸𝑞𝑢𝑖𝑣𝑎𝑙𝑒𝑛𝑡 = 27 + 26 + 25 + 24 + 22
= 128 + 64 + 32 + 16 + 4 = 244
The result is erroneous since the decimal value is larger than the maximum allowed decimal value using 8 bits. An
overflow has occurred.

(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

3. (i) With reference to operating system


(a) Paging and segmentation are two commonly used memory management techniques in operating systems.
Here are the key differences between the two:

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.

(ii) (a) Twisted Pair, Coaxial and Fiber Optic cables.

(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.

(c) SQL Query


SELECT COUNT(payment.trip_id) AS Number_of_Payments, trip.trip_id
FROM trip, payment
where trip.trip_id = payment.trip_id
GROUP BY trip_id;

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.

(b) Expression Tree


(c) Post-Order Traversal is used.

Post-Fix Order: ABCD/∗ +


(ii)(a) Trace Table
𝑋 𝑌 𝑁 T
0 1 8 -
1 1 7 0
1 2 6 1
2 3 5 1
3 5 4 2
5 8 3 3
8 13 2 5
13 21 1 8
21 34 0 13
𝑂𝑢𝑡𝑝𝑢𝑡 = 𝑅𝑒𝑠𝑢𝑙𝑡 = 21

(b) Deduction of computation


The Algorithm computes the nth term i.e. X = (n-1) + (n-2) hence it is using the principle Fibonacci that says
0 if n = 0
F(n) = { 1 if n = 1
Fn = Fn − 1 + Fn − 2 if n > 0
(c ) Complexity
TN = O(N)
7.(i)(a) It is the order in which individual statements, instructions or function calls of an imperative program are executed
or evaluated.

(b) Pre & Post Test Loops

(c)
- Pre-Test Loop: For or While loop
- Post-Test Loop: Do-while (Repeat-Until) loop.

(ii) (a) Outputs


(b) f2 is more efficient. This is because f2 is called only once thus using less time and space compared to f1.

(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.

(b) Test Data


Test data Justification
Normal/Valid data: Any integer ≥ 18 entered will display the message
age should be integer “you can vote” because it is within acceptable
≥ 18 voting age.
Abnormal/Invalid Any value < 18 entered the program should display
data: any age < 18 “you cannot vote”, because it is an unacceptable
age range.
Boundary data: 18 It is acceptable since it is the minimum voting age.
The program will display “you can vote” when 28
is entered.

You might also like