0% found this document useful (0 votes)
12 views19 pages

Computing Student Guide

Uploaded by

quancv2004
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)
12 views19 pages

Computing Student Guide

Uploaded by

quancv2004
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/ 19

ASSIGNMENT 1 FRONT SHEET

Qualification BTEC Level 5 HND Diploma in Computing

Unit number and title Unit 19: Data Structures and Algorithms

Submission date 18/06/2024 Date Received 1st submission 18/06/2024

Re-submission Date Date Received 2nd submission

Student Name Nguyen Tien Dat Student ID BH01250

Class IT0601 Assessor name Ta Quang Hieu

Student declaration

I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism. I understand that
making a false declaration is a form of malpractice.

Student’s signature DatG

Grading grid

P1 P2 P3 M1 M2 M3 D1 D2
 Summative Feedback:  Resubmission Feedback:

Grade: Assessor Signature: Date:

Internal Verifier’s Comments:

IV Signature:
Contents
I. Introduction............................................................................................................................................... 4
II. Body........................................................................................................................................................ 5
1. Specify the abstract data type for a software stack using an imperative definition.............................5
1. Data Structure....................................................................................................................................5
2. Types of data structures.....................................................................................................................5
3. Basic Data Structures........................................................................................................................ 7
4. push operation................................................................................................................................ 10
5. Pop operation.................................................................................................................................. 12
6. Peek operation................................................................................................................................ 13
2. Examine the advantages of encapsulation and information hiding when using an ADT.....................14
1. Encapsulation.................................................................................................................................. 14
2. Modularity and Maintainability.......................................................................................................15
3. Information Hiding.......................................................................................................................... 19
III. conclusion............................................................................................................................................. 22
IV. References............................................................................................................................................. 23

Figure 1 Data Structures............................................................................................................................... 6


Figure 2 Arrays............................................................................................................................................. 7
Figure 5 Linked Lists....................................................................................................................................8
Figure 8 Stacks............................................................................................................................................. 8
Figure 11 Queues..........................................................................................................................................9
Figure 14 Trees........................................................................................................................................... 10
I. Introduction
In today's software development environment, the use of Abstract Data Types (ADTs) plays a crucial role
in improving the design, development, and testing of software. ADTs not only help separate the
implementation from the interface but also enhance modularity and code reusability. By abstracting the
complexities and focusing on defining the operations that can be performed on the data, ADTs provide a
foundation for building robust and maintainable software systems. As the lead software project manager
at Soft Development ABK, my task is to introduce these methods to our collaborators to increase work
efficiency and enhance the overall quality of our software products. ADTs offer a way to structure data
and define the operations that can be performed on that data without specifying how these operations
are implemented. This abstraction allows developers to focus on the "what" rather than the "how,"
promoting a clear separation of concerns. This approach not only simplifies the design process but also
makes the code more adaptable to changes. When the underlying implementation needs to be modified,
the interface remains consistent, minimizing the impact on the rest of the system. This report will
demonstrate how to use ADTs to develop a student management system. This system allows users to
input student information, including student ID, name, and marks, and then rank students based on their
marks. The program will display detailed information about each student and provide functionalities to
add, edit, delete, sort, and search for students. These functionalities are essential for maintaining and
managing student records efficiently, ensuring that the data is always accurate and up-to-date. We will
begin by defining and identifying the necessary ADTs for this system. The core ADT in this context will be
the Student ADT, which encapsulates all relevant details about a student. We will also define operations
such as adding a new student, editing student information, deleting a student record, sorting the list of
students by marks, and searching for students by their ID. By clearly specifying these operations, we
establish a robust framework that guides the implementation phase. Next, we will present the
algorithms used to process and manage student data. For each operation, we will discuss the current
algorithms in use, their time and space complexities, and their suitability for our requirements.
Specifically, we will compare the efficiency of existing algorithms and propose an alternative algorithm to
improve the system's performance. For example, while a simple sorting algorithm like Bubble Sort may
be easy to implement, it may not be efficient for large datasets. We will explore more efficient sorting
algorithms such as Merge Sort or Quick Sort and evaluate their performance in our context. The goal of
this report is to provide a comprehensive overview of how to apply ADTs and efficient algorithms in
software development, thereby helping developers at Soft Development ABK and collaborators to apply
this knowledge effectively in real-world projects. By adopting these practices, we aim to enhance the
modularity, maintainability, and performance of our software systems. This report will serve as a guide
for integrating ADTs into our development workflow, highlighting the benefits and providing practical
examples of their application.
II. Body
1. Specify the abstract data type for a software stack using an
imperative definition.
1. Data Structure
Data structures serve as the physical manifestation of various data types, facilitating the effective
organization, storage, and retrieval of data within a computer's memory. While we can analyze the time
complexity and memory usage of data structures, individual data types cannot undergo the same
scrutiny. Additionally, the implementation of data structures can vary significantly across different
programming languages, offering developers flexibility in how they manage data.

At the heart of every software program lies a symbiotic relationship between data and algorithms.
Algorithms are the engines that transform raw data into actionable insights, while data structures
provide the framework for efficiently managing and accessing this data within memory. By leveraging
different combinations of data structures, developers can create tailored solutions that optimize
performance for specific data access patterns.

The choice of data structure profoundly influences the efficiency of algorithms. By selecting the most
appropriate data structure for a given task, developers can significantly enhance application processing
speed. This capability is paramount for managing massive amounts of data efficiently, whether it be for
large-scale indexing, handling massive databases, or supporting big data platforms. In essence, data
structures encompass a diverse array of methods for organizing and sorting data on computers, ensuring
optimal performance and resource utilization in software development.

2. Types of data structures


Primitive Data Structures
These are machine-level supported structures that can be used to create non-primitive data structures.
They are both essential and straightforward in nature, adhering to specific rules and specifications.
Examples include Integer, Float, Character, and Pointer. A pointer, however, does not store a data value
directly; instead, it holds the memory address of a data value. This type of data is also referred to as a
reference data type.

Non – Primitive Data Structures


Non-primitive data structures cannot be implemented without the original data structure. They originate
from primitive data structures and cannot be created without using them, even though they are also
provided by the system. Non-primitive data structures can be categorized into two types: simple data
structures and compound data structures.
Figure 1 Data Structures

3. Basic Data Structures

Arrays:

Figure 2 Arrays

Arrays are one of the simplest and most commonly used data structures. They store elements of the same
data type sequentially in memory and allow random access to elements based on their index. Arrays have
a fixed size and are efficient for accessing elements by index, but inserting or deleting elements can be
costly as it may require shifting other elements.
Linked Lists:

Figure 3 Linked Lists

Linked lists consist of nodes that are linked together by pointers or references. Unlike arrays, linked lists
do not have a fixed size and can dynamically grow or shrink as elements are inserted or removed. Linked
lists come in various forms such as singly linked lists, doubly linked lists, and circular linked lists. They
are efficient for insertion and deletion operations, especially when dealing with large datasets, but
accessing elements by index is slower compared to arrays.

Stacks:

Figure 4 Stacks

Stacks are a type of linear data structure that follows the Last In, First Out (LIFO) principle. Elements are
added and removed from the top of the stack, similar to stacking plates. Stacks are commonly used in
programming languages for function calls, expression evaluation, and backtracking algorithms.
Queues:

Figure 5 Queues

Queues are another type of linear data structure that follows the First In, First Out (FIFO) principle.
Elements are added to the rear of the queue and removed from the front, similar to waiting in line. Queues
are used in various applications such as scheduling tasks, managing resources, and implementing breadth-
first search algorithms.

Trees:

Figure 6 Trees

Trees are hierarchical data structures that consist of nodes connected by edges. Each node has a parent and
zero or more child nodes. Trees are used to represent hierarchical relationships and are commonly used in
data storage, file systems, and database indexing. Examples of trees include binary trees, binary search
trees, AVL trees, and B-trees.
4. push operation
The "push operation" is an action within the stack data structure. When performing a push operation, you
add an element to the top of the stack. This increases the size of the stack by one and places the new
element at the top. Existing elements below the top remain in their relative order.

Stack Push Operation: In a stack, the push operation adds an element to the top of the stack. The newly
added element becomes the new top, and any existing elements below it maintain their relative order. This
operation is also known as "pushing onto the stack."

Steps involved in the push operation on a stack:

1. Increment the stack pointer (or top pointer) to reserve space for the new element.
2. Place the new element at the memory location pointed to by the stack pointer.
3. Update the stack pointer to reflect the new top position.

Queue Push Operation: In a queue, the push operation is called "enqueue" and adds an element to the
rear or end of the queue. The newly added element becomes the last element in the queue, and any
existing elements maintain their relative order. This operation is also referred to as "appending to the
queue."

Steps involved in the enqueue operation on a queue:

1. Increment the rear pointer to reserve space for the new element.
2. Place the new element at the memory location pointed to by the rear pointer.
3. Update the rear pointer to reflect the new end position.
5. Pop operation
Pop operation is an operation within the stack data structure. When performing a pop operation, you
remove the element at the top of the stack and retrieve its value. This reduces the size of the stack by one
element.

Stack Pop Operation: In a stack, the pop operation removes the topmost element from the stack and
returns its value. This operation reduces the size of the stack by one element. The element directly
below the removed element (if any) becomes the new top of the stack.

Steps involved in the pop operation on a stack:

1. Retrieve the element at the memory location indicated by the top pointer.
2. Decrement the top pointer to reflect the removal of the element.
3. Return the retrieved element as the result of the operation.

Queue Pop Operation: In a queue, the pop operation is called "dequeue" and removes the front or first
element from the queue. The removed element's value is returned as the result of the operation. This
operation decreases the size of the queue by one element. The element next in line (if any) becomes the
new front of the queue.

Steps involved in the dequeue operation on a queue:

1. Retrieve the element at the memory location indicated by the front pointer.
2. Increment the front pointer to reflect the removal of the element.
3. Return the retrieved element as the result of the operation.
6. Peek operation

Peek operation is an operation performed on a stack data structure. This operation retrieves the value of
the element at the top of the stack without removing it. It allows accessing and examining the value of the
top element without altering the state of the stack.

Stack Peek Operation: In a stack, the peek operation retrieves the topmost element from the stack
without removing it. This operation allows you to inspect the element at the top of the stack without
altering the stack itself.

Steps involved in the peek operation on a stack:

1. Retrieve the element at the memory location indicated by the top pointer.
2. Return the retrieved element as the result of the operation.

Queue Peek Operation: In a queue, the peek operation retrieves the front or first element from the queue
without removing it. This operation allows you to examine the element at the front of the queue without
changing the queue itself.

Steps involved in the peek operation on a queue:

1. Retrieve the element at the memory location indicated by the front pointer.
2. Return the retrieved element as the result of the operation.
2. Examine the advantages of encapsulation and information hiding
when using an ADT.
1. Encapsulation
Encapsulation is a fundamental principle in object-oriented programming that refers to the bundling of
data and methods that operate on the data into a single unit called a class. It involves hiding the internal
state of an object and restricting direct access to them from outside the class. Instead, access to the data
is typically provided through public methods which are part of the class interface.

Data Protection
Data protection refers to the practice and techniques used to safeguard data from corruption,
unauthorized access, loss, or theft. It involves implementing measures and controls to ensure that data
remains secure and available only to authorized users or processes. The goal of data protection is to
maintain the confidentiality, integrity, and availability of data throughout its lifecycle.

Example in the project:

In this Student class, the fields id, name, and marks are private, so they cannot be accessed directly from
outside the class.
2. Modularity and Maintainability
Modularity and Maintainability are two crucial principles in software design and development. Modularity
is a software design principle where the system is divided into smaller, independent components or
modules. Each module performs a specific function and can be developed, tested, and maintained
separately. This offers several advantages such as ease of maintenance, code reuse, parallel development,
and easier testing. On the other hand, Maintainability is the ability of the software to be easily repaired,
upgraded, and improved. Software with high maintainability allows for understanding, fixing bugs, or
adding new features quickly and efficiently. This helps reduce maintenance costs, enables continuous
improvement, extends the software's lifespan, and facilitates onboarding for new developers. Both
principles are essential to ensure that the software is structured clearly, easy to understand, and can be
effectively developed and maintained over a long period.

The purpose of this line of code is to categorize students' marks into predefined ranges to identify who has
achieved high and low grades. By using the method, each student's marks are evaluated against specific
thresholds (0-5.0 for Fail, 5.0-6.5 for Medium, 6.5-7.5 for Good, 7.5-9.0 for Very Good, and 9.0-10.0 for
Excellent). This categorization allows educators to quickly understand and differentiate students' academic
performance levels. It simplifies the process of providing targeted feedback, assessing progress, and
implementing appropriate educational interventions based on each student's achievement level. Thus,
plays a vital role in educational contexts by facilitating effective student assessment and support,calculate
Rank

Functions to add, edit and delete code

The student management system includes several key functionalities designed to facilitate efficient
management of student data: adding students, editing student information based on ID validation, and
deleting students.

Adding Students: Users can input new student details including ID, name, and marks. This functionality
allows for the seamless integration of new students into the system, ensuring all necessary information is
captured accurately from the outset.

Editing Students: This feature enables users to correct any inaccuracies or omissions in student
information by searching for a student based on their unique ID. If an incorrect or incomplete ID is
entered, the system provides feedback indicating an error. Once the correct student is identified, users can
update their details to ensure data integrity and accuracy.

Deleting Students: Users have the ability to remove students from the system by specifying the student's
ID. This process ensures targeted removal of individual student records, maintaining data hygiene and
relevance within the student management database.
Student sorting function

In a student management system, the function to sort grades from highest to lowest plays a crucial role in
effectively organizing and managing student data. As the number of students and their grade information
increases, this feature helps users easily identify and evaluate academic achievements. Sorting data
enhances user experience by reducing search time and improving data accuracy. Moreover, it supports
efficient management by providing a clear and consistent structure for analyzing academic performance
and implementing tailored educational strategies for each student. The consistency and transparency of
sorted data ensure that information provided and utilized within the system is accurate and reliable.
Therefore, this function serves not only as a valuable tool in student management but also as a critical
factor in optimizing assessment and management processes in educational institutions and training
settings.

Student search function and display all students

Search for Students by ID: Users can input a student's ID and retrieve specific details about that student.
This capability ensures quick access to individual student records, facilitating efficient tracking of
academic progress and administrative tasks.
Display All Students: Additionally, users can choose to display a comprehensive list of all students
enrolled in the system. This function provides an overview of the student body, allowing administrators
and educators to gather necessary information for various purposes such as reporting, analysis, or
communication.

3. Information Hiding
Hiding student information refers to the process of safeguarding sensitive details about students from
unauthorized or improper access within a student management system. This is achieved using
techniques such as encapsulation in programming to protect data, allowing access only through
controlled methods. Information such as student ID, name, grades, and other sensitive details are
shielded to prevent unauthorized interference and ensure the security and integrity of the system.

Abstraction
Abstraction in computer science and programming refers to the process of focusing on essential aspects
of a system or object while ignoring unnecessary details. It allows developers to create simplified models
of complex real-world entities, reducing complexity and enhancing the conceptualization in
programming.

In programming, abstraction is implemented through abstract data types, classes, and interfaces. These
constructs hide specific implementation details such as memory management or complex algorithms,
focusing instead on defining clear interfaces and behaviors that are essential for achieving desired
functionality.

Example in the project:


In the provided Student class, Abstraction is effectively applied to manage student information safely and
efficiently. Data fields such as studentId, name, grade, and rank are protected by being defined as private,
not directly accessible from outside the Student class. This ensures data security and integrity. Instead,
getter methods getStudentId, getName, getMarks, getRank are provided to retrieve student information in
a controlled and secure way. Users can use these methods to retrieve the values of properties without
knowing the details of how the data is stored and processed internally.

Improved Security
Improved security refers to the enhancement of measures and practices to protect data, systems, and
networks from unauthorized access, attacks, breaches, and other forms of malicious activities. It involves
implementing stronger defenses to ensure the integrity, confidentiality, and availability of information.

Example in the project:


In the Student class, the fields id, name, and marks are declared as private, ensuring that they cannot be
accessed or modified directly from outside the class. This encapsulation prevents external code from
inadvertently altering the internal state of a Student object in an unintended or inconsistent manner. All
interactions with these fields must be conducted through the public methods provided by the class. This
approach allows for enforcing validation rules or constraints, ensuring data integrity and maintaining the
expected behavior of the Student objects within the application.

III. conclusion
In the realm of software development, understanding Abstract Data Types (ADTs) and their specifications
is crucial for designing robust and efficient systems. ADTs provide a formal way to define data structures
and operations, offering a blueprint for developers to implement and utilize these structures effectively.
Throughout this exploration, we have delved into various aspects of ADTs, starting with their formal
specification using notations like ASN.1, and non-executable languages such as SDL and VDM. These
specifications define the operations that can be performed on data structures like stacks, queues, lists,
trees, and more. Each data structure comes with its own set of operations, pre-conditions, post-conditions,
and error-handling mechanisms, ensuring safe and predictable behavior during execution. We have
examined how ADTs enhance software development by promoting encapsulation and information hiding.
Encapsulation safeguards data within ADTs, fostering modularity, maintainability, and reusability.
Information hiding reduces complexity by abstracting away implementation details, thereby enhancing
security and improving overall code quality.

Furthermore, in exploring algorithm types such as recursive, dynamic, greedy, and others, and specific
algorithms like sorting (e.g., insertion, merge) and shortest path algorithms (e.g., Dijkstra's, Prim-Jarnik),
we have seen how ADTs play a pivotal role. They provide the foundational structures and operations upon
which these algorithms operate, facilitating efficient problem-solving in diverse computational scenarios.
In practical terms, as an in-house software developer at Soft Development ABK, understanding and
leveraging ADTs can significantly benefit project management. These concepts empower teams to build
applications that efficiently manage and manipulate data, solve complex problems using advanced
algorithms, and ensure robust performance through well-defined design specifications.

Looking ahead, as software continues to evolve, ADTs remain essential. They serve as a cornerstone for
object-oriented programming paradigms, offering a procedural foundation that supports modularity,
reusability, and scalability. By mastering ADTs and their specifications, developers can navigate
complexities in software development, enhance productivity, and deliver solutions that meet the
demanding requirements of modern applications.

IV. References
 Secoda (No Date) How to ensure modularity and reusability in data pipelines, Secoda. Available
at: https://www.secoda.co/blog/how-to-ensure-modularity-and-reusability-in-data-pipelines
(Accessed: 18 June 2024).
 Www.naukri.com (No Date) Peek() Operation in Stack, Code 360 by coding ninjas. Available at:
https://www.naukri.com/code360/library/peek-operation-in-stack (Accessed: 18 June 2024).
 GeeksforGeeks (2022). Introduction to Stack memory. [online] GeeksforGeeks. Available at:
https://www.geeksforgeeks.org/introduction-to-stack-memory/ [Accessed 18 Jun. 2024].
 GeeksforGeeks (2018). FIFO (First-In-First-Out) approach in Programming. [online]
GeeksforGeeks. Available at: https://www.geeksforgeeks.org/fifo-first-in-first-out-approach-in-
programming/ [Accessed 18 Jun. 2024].
 baeldung (2018). Baeldung. [online] Baeldung. Available at: https://www.baeldung.com/java-
stack-heap#:~:text=Stack%20Memory%20in%20Java%20is,%2DOut%20(LIFO)%20order.
[Accessed 18 Jun. 2024].

You might also like