0% found this document useful (0 votes)
8 views

2306387 Assignment 2 Data structures

The document discusses Abstract Data Types (ADTs) and their advantages over concrete data types in software applications, emphasizing flexibility and maintenance. It also evaluates suitable data structures for a university timetable management system, including arrays for class schedules, linked lists for teacher assignments, and queues for student registration, detailing their advantages and limitations. Additionally, it explains Dijkstra's Algorithm for finding the shortest path in a weighted graph and its application in real-world scenarios like Google Maps, highlighting its efficiency in handling large datasets and adapting to real-time data.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

2306387 Assignment 2 Data structures

The document discusses Abstract Data Types (ADTs) and their advantages over concrete data types in software applications, emphasizing flexibility and maintenance. It also evaluates suitable data structures for a university timetable management system, including arrays for class schedules, linked lists for teacher assignments, and queues for student registration, detailing their advantages and limitations. Additionally, it explains Dijkstra's Algorithm for finding the shortest path in a weighted graph and its application in real-world scenarios like Google Maps, highlighting its efficiency in handling large datasets and adapting to real-time data.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

CHRISTIAN MWENDA GITONGA

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.

ii. Teacher Assignments (Linked lists)


Advantages
Supports efficient data manipulation by allowing quick insertion and deletion of
elements.
They allocate memory adaptively so there is no need of predefining the size.
Limitations
Has a higher time complexity for random access if the list grows large.
It may require more memory than an array data.

iii. Student Registration(Queues)


Advantages
FIFO
Efficient for adding students and processing students.
Limitations
They are not suitable for random access or direct modification of the data.
They are not suitable for complex requests because you will have to go through the
entire structure.
QUESTION 3
1. Graph theory plays a crucial role in algorithms, especially in finding optimal paths.
Explain Dijkstra's Algorithm and provide a step-by-step example showing how it would
determine the shortest path from one node to another in a network of five nodes. Use
a diagram to illustrate your answer.
Dijkstra’s Algorithm is used to find the shortest path from a single starting point to all
the other nodes in a weighted graph.
i. Start by initializing the distance to infinity for all the nodes.
ii. Create a set of visited nodes.
iii. Set the distance of the start node to 0.
iv. Repeat until all nodes are visited.
v. Find the unvisited node with the lowest distance.

2. Describe a real-world scenario where Dijkstra's Algorithm could be effectively applied,


detailing the specific advantages it offers in this context.
Google maps uses this Dijkstra’s algorithm to find the most efficient path between
the starting location and the destination considering various factors like traffic and
weather.
Advantages
It ensures the shortest path in terms of distance is chosen saving time and fuel costs.
It can efficiently handle large datasets by breaking them down into manageable
steps as navigation systems like google maps deals with large road networks.
It can adapt to the real time data.

You might also like