April
1999 QUESTION 1 (Compulsory) Total Marks: 20 Marks |
Click here to access other
questions
Click to access
|
(a) | Briefly explain each of the following terms: | |
(i) Array. | [2] | |
(ii) List. | [2] | |
(iii) Iteration | [2] | |
(iv) Recursion
|
[2] | |
(b) | (i) Define a RECORD, called EmployeeId,
which contains the following fields:
You can assume the definition of a pointer to the EmployeeID type as follows: EmployeeIDPtr = EmployeeId;
|
[3] |
(ii) Given the following definition of a linked
list of type EmployeeID as above,
write a recursive procedure, called NumberOfNodes that will return the number of nodes in a linked list consisting of the
record type above. The procedure should return zero if the list is empty. You can assume
the existence of a Boolean function isEmpty, which will return TRUE
if the list is empty, and FALSE otherwise. TYPE
|
[4] | |
(c) | Assume the following definitions of the types One, Two, Three, and Four: TYPE One = ^OneItem; CONST Max = 20; TYPE Three = ^ThreeItem; TYPE FourPtr = ^FourItem;
|
|
Which of these types would be best best suited to represent the following? | ||
(i) A stack of integers. | [1] | |
(ii) A static (i.e., fixed maximum size) queue of integers. | [1] | |
(iii) A double linked list of integers. | [1] | |
(iv) A dynamic (i.e. arbitrary length) queue of integers. | [1] | |
(v) A binary tree containing integers at the leaves. | [1] |