Professional Documents
Culture Documents
b. Outline the differences among a stack, a queue and a linked list [3mks]
A stack allows for additions and deletions to be done at only one end of
the list called the top while a queue allows for additions to be performed at
one end called the rear and deletions done at the other end called the front;
a linked list allows insertiions and deletions at any point in the list.
2. Write C code for the following stack operations. The stack is implemented as a fixed
size array where TOP and MAX are global variables used to represent the index of the
item at the top of the stack and the maximum number of items in the stack
respectively. Represent the code as functions such that the stack array, stack, is
accepted as a parameter.
a. PUSH [7mks]
void push(stack, x)
{
if(TOP == MAX - 1)
{
if(TOP == -1)
{
3.
a. State ONE advantage of using the waterfall approach to software development
[1mk]
Simple to follow step-by-step; Has set deliverables; Most commonly used
Takes a long time to produce deliverables since each stage must be completed
before the next can begin
6. Define the following terms and provide ONE example of EACH to support your
answer: [4 mks]
a. Functional requirements
Outlines the operations/tasks that a system should be able to do
b. Non-functional requirements
Constraints that the system may have or need to operate under
7. Outline two situations that can cause software to enter the maintenance phase [4 mks]
Environment change; Errors amd bugs; Security risks; Additional features/requirements
(Short description for each)
8. Outline the difference between ‘preemptive scheduling’ and ‘non-premptive
scheduling’ algorithms. [2 mks]
Preemptive scheduling can stop a running process to allow another process the
9. Two processes, P0 and P1, each require the use of two resources R0 and R1. With the
aid of a clearly labelled diagram, explain how deadlock could occur in this scenario.
[5 mks]
P0
Requests
Held by
R0
R1
Held by
Requests
P1
P0 has the resource R1, which it will not relinquish, and wants access to R0.
P1 currently wants R1 while holding holding R0, which it will not relinquish.
This results in both processes being blocked as they each wait on the other and
neither will concede