2306387 Assignment 2 Data structures
2306387 Assignment 2 Data structures
23/06387
ASSIGNMENT 2
QUESTION 1
1. Define the concept of an Abstract Data Type (ADT) and explain how it differs from
concrete data types.
An abstract data type(ADT) is a data type that defines a set of values and operations that can be
performed on data but doesn’t dictate how these operations are implemented. It defines data
structure by behavior rather than its concrete implementation.
ADTs define what operations are performed and the behavior expected but do not specify the
implementation details while concrete data types define both how data is structured and what
operations can be performed.
2. Describe two scenarios where using an ADT provides an advantage over concrete data
types in terms of flexibility and maintenance in a software application. Provide specific
examples in your answer.
i. If you have a database where you need to store and access records you can use ADT
like a hash table to store and access the records. You will have the flexibility to
choose a specific implementation of the hash table such as an array-based or lis-
based implementation without affecting the code that uses the ADT.
ii. If you are running a search engine you can use ADT as the sorting algorithm provides
maintenance advantages as any changes required to the sorting algorithm can be
made without affecting the code that uses it.
QUESTION 2
Consider a university timetable management system that needs to handle various data
structures effectively.
1. Identify and justify which data structures (e.g., arrays, linked lists, stacks, queues)
would be best suited to manage the following components of the system:
o Class schedules – Arrays because they would allow for quick retrieval of class
schedules based on the date, class and teacher information.
o Teacher assignments – Linked lists because they allow you to insert and delete
elements without affecting the rest of the structure and also displays a dynamic list of
teachers and the classes they are assigned to.
o Student registration – Queue as it allows the First-In-First-Out(FIFO) principle where
the first students to register are processed first ensuring fairness.
2. Describe how each chosen data structure supports efficient data manipulation for the
specified component, addressing the advantages and any potential limitations in each
case.
i. Class Schedules(Arrays)
Advantages
They support efficient data manipulation by allowing quick access and retrieval of
class information.
They are simple to implement.
You can easily access consecutive elements in arrays.
Limitations
They are fixed in size it is difficult to resize the array.
They are not flexible to changes if the schedule will require frequent updates arrays
will be inefficient.