August 1999
AP207 : ADVANCED PROGRAMMING TECHNIQUES

QUESTION 2

Total Marks: 20 Marks

Click here to access other questions

Click to access
SUGGESTED SOLUTIONS
for Question 2

(a) (i) Explain what is meant by the terms FIFO data structures and LIFO data structures.

(ii) Describe what is meant by the term abstraction.

(iii) Identify and explain the difference between a static and dynamic data structure.

 

[2]

[2]

[2]

(b) You are to develop a book control system for a library. The library needs to store the following information on each book :
  • The title of the book (a string 100 characters long);
  • The catalogue number of the book (an integer);
  • The status of the book, wither on loan or in the library (an integer);
  • The due date of return of the book (the Date type given below).

TYPE Date = RECORD

Day : Integer of [1..31];
Month : Integer of [1..12];
Year : Integer of [0..99];

END;

(i) Define a data structure Book, which contains all of the information above.

(ii) The library holds 1000 books in total. Define a suitable static data structure, called StaticLibraryCatalogue which will hold the details of all 1000 books.

(iii) Suppose that more books need to be added to the library. Suggest a suitable dynamic data structure, called DynamicLibraryCatalogue which could be used to hold the data as the number of books held in the library changes, and explain why your suggested data structure is suitable.

(iv) Implement a function
Function IsDateValid(MyDate : Date): BOOLEAN
which uses a case statement, and checks that the value of day is valid for the month. The function should return TRUE if the data is valid, and FALSE otherwise. (For example, if the day were given as 30 and the month as 2, the function would return false; but if the day were given 30 and the month 6, the function would return true.)

(v) A problem exits with the year field in date. Explain what this problem is, and give a new definition of the Date structure which solves it.

 

 

 

 

 

 

 


[4]


[1]


[2]

 


[5]

 




[2]