SECTIONC:Structured questions
• Answer all the questions in the provided booklet.
• The section consists of 15 problems.
Problem Cl
What is an algorithm?
Problem C2
Which data Structure uses Last-In First-out (LIFO)principle?
Problem C3
Consider the following two lists given below:
A= { 7, 9, 0, 11, 5, 3, 2, 1, 8}
B = {0, 1, 2, 3, 5, 7, 8, 9, 11}
Which one would you say is a better way of storing data? Justify your answer
[70 Marks]
[2 Marks]
[1 Mark]
[3 Marks]
Problem C4
Analyse the fragment of a program given below:
mysteryFunction(array,n)
FOR(i = 0; i < n - 1; i++)
min= i
FOR(j= i + 1; j < n; j++)
IF(arrayU] < array[min])THEN
min= j
ENDIF
ENDFOR
temp= array[i]
array[i] = array[min]
array[min] = temp
ENDFOR
If the calling part of the program passesthe following array {13, 2, 10, 15, 20, 17, 1} to
mysteryFunctio n(array, n)
a) What is the general task performed by the function given above?
[1 Mark]
b) How many times does the inner loop iterate?
[2 Marks]
c) Write down the state of the array on each pass of the outer loop, from the initial array given
above to the final array.
[6 Marks]
Problem CS
The following are statements to insert an integer element/ data into a non-empty static queue. [5 Marks]
a. Check if the queue is full
i. lfthe queue is full, display an appropriate message
b. If the queue is not full
i. Move rear to the next index
ii. Insert the element/ data in the queue
4