December
1999 QUESTION 5 Total Marks: 15 Marks |
Click here to access other
questions
SUGGESTED SOLUTIONS |
Consider the following abstract data type declaration for an IntegerList type:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(a) |
Explain the difference between deep and shallow (or member-wise) copying of objects. A shallow
copy is the default copy for objects passed by value to a function;
|
[3]
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(b) |
Write a constructor function for the IntegerList class which performs a deep copy of the object.You may not use any library functions. A sample definition of the constructor function IntegerList follows:
And the following
marking scheme should be used:
|
[6]
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(c) |
Write a function Reverse ,the signature
of which is given below,which takes an IntegerList object and returns
a new IntegerList which is the reverse of the original IntegerList
.You may not use any library functions. A sample definition of Reverse follows:
And the following
marking scheme should be used: |
[6]
|