August
1999 QUESTION 1 (Compulsory) Total Marks: 20 Marks |
Click here to access other
questions
Click to access |
(a) | Briefly explain the following terms : (i) Sorting (ii) Searching (iii) White box testing (iv) Black box testing
|
[1] [1] [1] [1] |
(b) | (i) Explain, informally, how a selection sort
works, and state how many passes of an unsorted list of length N it will take to
ensure the list is sorted. (ii) Explain, informally how a binary search works, and state the maximum number of passes it will take over a list of length N to find an item.
|
[3]
[3] |
(c) | Given the following definition of a binary
tree, and the procedure FooBar TYPE
PROCEDURE (FooBar VAR root : TreeType; item : Integer)
END; (i) Describe the effect of the procedure FooBar on the root of a tree like the one above. (ii) Assuming an initially empty tree, illustrate, with the aid of a diagram, the tree resulting from the following code fragment : Foobar(6);
|
[2]
[4] |
(d) | Write a recursive function, Power, which takes
two integer arguments, x and y, and returns xy. You can assume that both
parameters will be greater than zero.
|
[4] |