You are on page 1of 5

Computer Science Unit 2

End-of-Term Exam Questions


Section I – MCQs (10mks)
1. A queue is a data structure in which elements
a. Can only be added to the front and removed from the rear
b. Can only be added and removed from the rear
c. Can only be added and removed from the front
d. Can only be added to the rear and removed from the front
2. In a binary search
a. The number of items being searched is halved on every iteration
b. The list of data items is searched randomly
c. The list of data items is searched one by one until the target is found or the list
is exhausted.
d. The list of data items may be unordered
3. Which of the following is TRUE for BOTH a linear search and a binary search?
a. On average they search half the list
b. In the worst case scenario they search the entire list
c. They can be used for searching an ordered list
d. They require that the list be ordered.
4. Which of the following statements is a specification of a set of data and the set of
operations that can be performed on the data?
a. Library
b. ADT
c. Package
d. Tracer
5. Which of the following is TRUE?
a. The bubble sort performs better than selection sort on longer lists
b. The selection sort performs better on a partially ordered list than a completely
unordered list
c. The bubble sort is very simple and therefore very efficient
d. The selection sort performs the same regardless of the size of the list
6. Which sequence of operations would transform the queue from the initial state to the
final state shown below?

a. DEQUEUE, ENQUEUE(K), ENQUEUE(L)


b. ENQUEUE(L), ENQUEUE(K), DEQUEUE
c. DEQUEUE, DEQUEUE, ENQUEUE(L), ENQUEUE(K), ENQUEUE(J)
d. DEQUEUE, DEQUEUE, ENQUEUE(J), ENQUEUE(K), ENQUEUE(L)
7. A queue is implemented using an array. A procedure to add an element to the queue
would involve:
a. Incrementing the pointer to the front of the queue
b. Incrementing the pointer to the rear of the queue
c. Decrementing the pointer to the front of the queue
d. Decrementing the pointer to the rear of the queue
8. Software that is NOT associated with the wasting of resources is said to have the
property of
a. Efficiency
b. Reliability
c. Dependability
d. Usability
9. One of the MAIN weaknesses of the waterfall model is that it:
a. Requires significant technical support
b. Encourages an increase in project size
c. Is an inflexible development model
d. Consumes a lot of time and resources
10. Two processes are said to be deadlocked when
a. They are awaiting I/O
b. They are denied CPU time by processes with higher priority
c. Neither can proceed because each is waiting on the other to do something
d. They are about to be killed

Section II – Written Problems


1.
a. Briefly describe the concept of an ‘abstract data type’ (ADT) [2mks]
Refers to a way of storing and manipulating data using a data structure
and the set of pre-defined functions to carry out the operations that
manipulate the data structure

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)
{

printf "The stack is full"


}
else
{
TOP++
stack[TOP] = x
}
b. }POP [8mks]
int pop(stack)
{
int value;

if(TOP == -1)
{

printf ("The stack is empty") ;


} else {
value = stack[TOP];
TOP--
}
return value
}

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

b. State TWO disadvantages of using the waterfall approach to software


development [2 mks]
Inflexible compared to other approaches

Little feedback/interaction with customers (after requirements definition)


Time consuming and expensive to address errors in later stages

Takes a long time to produce deliverables since each stage must be completed
before the next can begin

4. Briefly describe EACH of the following terms:


a. White box testing [2 mks]
Testing of functions/modules where the tester has knowledge of the code
b. Black box testing [2 mks]
Testing only the inputs and expected outputs for the function/module

c. Test cases [2 mks]


A set of varied inputs and expected outputs from a given system

5. List THREE properties of a well-engineered software product. [3 mks]


Maintainability, Dependability, Efficiency, Usability, Portability, etc

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

Eg: Print list of user names to the screen

b. Non-functional requirements
Constraints that the system may have or need to operate under

Eg: Response time of less than 1 second

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

chance to execute while non-preemptive scheduling allows a running process


to continue execution until it is terminated or blocked

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

10. List THREE types of malware [3 mks]


Viruses, Worms, Bots, Ransomware, Rootkit, Key logger, etc

You might also like