Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

FACULTY OF SCIENCE

ACADEMY OF COMPUTER SCIENCE & SOFTWARE ENGINEERING

MODULE IFM01B1 / IFM1B10


INTRODUCTION TO DATA STRUCTURES (VB)

CAMPUS APK

EXAM Paper 1

DATE 2022 SESSION 08:30 to 11:30

ASSESSORS D COTTERRELL
HJC VAN DER WESTHUIZEN

INTERNAL MODERATOR K LEBEA

DURATION 120 MINUTES MARKS 100

THIS QUESTION PAPER CONSISTS OF SEVEN (5) PAGES INCLUDING THE COVER PAGE

INSTRUCTIONS:

• ANSWER ALL QUESTIONS.


• PLEASE WRITE NEATLY AND LEGIBLY – THE LECTURERS RESERVE THE RIGHT
TO NOT AWARD MARKS IF THEY CANNOT DISCERN WHAT WAS WRITTEN.
• IF A SHORT QUESTION IS OUT OF X MARKS, ONLY THE FIRST X ANSWERS
PROVIDED WILL BE MARKED.
• ANSWERS MUST PERTAIN TO THE MATERIAL COVERED IN THE MODULE.

1
IFM01B1 / IFM1B10: INFORMATICS 1B – NOVEMBER EXAMINATION 2022

QUESTION 1 (UML)
Draw the UML class diagram to demonstrate the concepts of Inheritance, Composition and
Interfaces by considering the class Bird.

1.1 Define the Bird class – it must have at least two attributes and one (2)
appropriate method (constructor and property methods do not count).

1.2 Define two additional classes which both inherit directly from Bird – they (4)
must each have two attributes and one appropriate method each
(constructor, property methods, and overridden methods do not count).

1.3 Using one of the derived classes demonstrate composition. The (2)
component class must consist of two attributes, and one method
(constructor and property methods do not count).

1.4 Given an example of an interface implemented in class defined in (2)


question 1.1.

1.5 Be sure to use the correct logic and correct UML notation. (5)

[15]

2
IFM01B1 / IFM1B10: INFORMATICS 1B – NOVEMBER EXAMINATION 2022

QUESTION 2 (Recursion)
a) In terms of x, y, and z, what does the following function calculate? (5)

1: Private Function CalR (x As Integer, y As Integer, z As Integer) as Integer


2: If a < 2 Then 'Assume that a will always start >= 2
3: Return 1
4: Else
5: Return (x * y) / CalR(x, y , z-2)
6: End If
7: End Function

If you believe that the function calculates x + y + z, then your answer should be
x + y + z.
Clearly indicate your final answer.

b) Write the recursive function based on the following formula in Visual Basic (5)
code:

[10]
QUESTION 3 (Programming)
Consider the following classes Planet (is the base class), GasPlanet, DwarfPlanet,
HeavyPlanet and frmQuestion3. Using the classes provided above, demonstrate that you
understand the following programming concepts by writing sufficient and appropriate Visual
Basic code (i.e. the code must be relevant to the above classes) to illustrate the concepts in
question:
a) Inheritance {VB} (3)
b) Upcasting {VB} (3)
c) Polymorphism {VB} (2)
d) Composition {VB} (3)
e) Downcasting {VB} (4)
f) Overriding with extension {VB} (6)

NB!!!
• Clearly indicate where each class begins and where each class ends.
• Clearly indicate where you are attempting to illustrate a particular concept in your code.

3
IFM01B1 / IFM1B10: INFORMATICS 1B – NOVEMBER EXAMINATION 2022

[21]
QUESTION 4 (Collision Handling)
You have been provided with the following table that contains the hashed values of the keys.
You need to place the value into a random-access file in the order they are listed in the table
below (entry value is the insert order). The file can only handle 13 values. Given that the
records are inserted into the file in the order tabled below, illustrate the contents of the full
random-access file if the following collision handling methods are used:

Entry Key Position


1 Lamp 1
2 Carpet 2
3 Bed 5
4 Couch 7
5 Bowl 1
6 Mouse 2
7 Table 4
8 Painting 4
9 Dog 6
10 Rat 8
11 Bug 1

a) Linear Probing + notation (6)


b) Separate Overflow + notation (6)
c) Bucket address (bucket size 3) + notation (6)
[18]
QUESTION 5 (Sequential Files)
You are to consider the classes Fish, Shark, and Tropical which will be used to develop a
Visual Basic application that saves all Fish objects to a sequential file. Provide syntactically
correct Visual Basic code (along with any necessary declarations) for the following
questions:
a) Declare the required variables for a sequential file? {VB}. (2)
b) Create the file called “Question5.ifm” and save all the Fish objects to the file. (6)
{VB}.
c) Assume all required variables to read from a file have been declared. The file (5)
stream FS is open in read access mode. You need to write the code to read
only the Tropical objects that have been saved to the file. You do not need to
worry about closing the file. [13]
{VB}.

4
IFM01B1 / IFM1B10: INFORMATICS 1B – NOVEMBER EXAMINATION 2022

QUESTION 6 (Random Access Files)


Consider the following record structure which must be used to save records in a random-
access file containing 9 records:

1: Private Structure Bike


2: Public ID As Integer
3: <VBFixedString(8)> Public Model As String
4: <VBFixedString(19)> Public Brand As String
5: Public numGears As integer
6: Public Weight As Double
7: End Structure

Where applicable (this will be denoted by {VB} in the question), provide syntactically correct
Visual Basic code (along with any necessary declarations) for the following questions:

a) What is the maximum byte size of the record structure called Bike? Show the (3)
working out.
b) Provide a function called CalcFilePos that will return the file position of a given (3)
record key. {VB}
c) Create a sub routine to save a given record to file using the filename “Question (6)
6.dat” make use of the function created in question 6b. {VB}
d) What type of a function is used in Question 6b? (1)
[13]

QUESTION 7 (Social Aspects of IT)

Discuss how a study of the different Belbin roles can contribute to better team cohesion in
software engineering projects. Would understanding the Belbin roles helped in how your
team assignment was managed, explain how?

Additional, discuss two of the personal challenges you encountered and how you may go
about to address these challenges better in future when it came to the group assignment.
[10]

 THE END

You might also like