April 2000
AP207 : ADVANCED PROGRAMMING TECHNIQUES

QUESTION 1 (Compulsory)

Total Marks: 30 Marks

Click here to access other questions

Click to access
SUGGESTED SOLUTIONS
for Question 1

(a)Explain what is meant by the following terms:
(i)Array [2 marks ]
(ii)White box testing [2 marks ]
(iii)List [2 marks ]

(b)(i)Explain how a binary search works.[3 marks ]
(ii)Explain how hashing works.[3 marks ]

(c)Assume the following declaration of a dynamic binary tree and the procedure FooBar

(i)Describe the effect of FooBar on the root of a tree like the one above.[2 marks ]
(ii)Assuming an initially empty tree,illustrate,with the aid of a diagram,the tree
resulting from the following code fragment:
Foobar(10);
Foobar(3);
Foobar(12);
Foobar(4);
[4 marks ]

(d)(i)Define a type,called MyType which can be used to store up to 50 real
numbers.[1 mark ]
(ii)Define a variable,MyVariable which consists of an array of 10
[1 mark ]

(e)Given the following declaration of the type NUMTYPE
const max= 200;
TYPE NUMTYPE= array[1..max] of INTEGER;
(i)Using a while loop,write a procedure,called Initialise that takes a its
argument a parameter of type NUMTYPE and initialises all the elements of the
parameter to the value -1 [5mark ]
(ii)Write a recursive function Biggest which takes as it argument a parameter of
type NUMTYPE and returns the largest element in the array.[5 marks ]