You are on page 1of 18

Higher Nationals in Computing

Unit 19: Data Structures and


Algorithms
ASSIGNMENT 1

Assessor name: PHAN MINH TAM

Learner’s name: NGO HUU DUY


ID: GCS200881
Class: GCS1001B
Subject code: 1649

Assignment due: Assignment submitted:


ASSIGNMENT 1 FRONT SHEET

Qualification BTEC Level 5 HND Diploma in Computing

Unit number and title Unit 19: Data Structures and Algorithms

Submission date Date Received 1st submission

Re-submission Date Date Received 2nd submission

Student Name Ngo Huu Duy Student ID GCS200881

Class GCS1001B Assessor name Phan Minh Tam

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

Grading grid
P1 P2 P3 M1 M2 M3 D1 D2
❒ Summative Feedback: ❒ Resubmission Feedback:

Grade: Assessor Signature: Date:

Internal Verifier’s Comments:

Signature & Date:


ASSIGNMENT 1 BRIEF

Qualification BTEC Level 5 HND Diploma in Business

Unit number Unit 19: Data Structures and Algorithms

Assignment title Examine and specify ADT and DSA

Academic Year 2022

Unit Tutor TamPM

12 – September –
Issue date Submission date
2022

IV name and date

Submission Format:

Format:

● The submission is in the form of an individual written report and a presentation. This should be written in a concise,
formal business style using single spacing and font size 12. You are required to make use of headings, paragraphs and
subsections as appropriate, and all work must be supported with research and referenced using the Harvard referencing
system. Please also provide a bibliography using the Harvard referencing system.

Submission

● Students are compulsory to submit the assignment in due date and in a way requested by the Tutor.
● The form of submission will be a soft copy posted on http://cms.greenwich.edu.vn/.
● Remember to convert the word file into PDF file before the submission on CMS.

Note:

● The individual Assignment must be your own work, and not copied by or from another student.
● If you use ideas, quotes or data (such as diagrams) from books, journals or other sources, you must reference your
sources, using the Harvard style.
● Make sure that you understand and follow the guidelines to avoid plagiarism. Failure to comply this requirement will
result in a failed assignment.

Unit Learning Outcomes:


LO1 Examine abstract data types, concrete data structures and algorithms

LO2 Specify abstract data types and algorithms in a formal notation

Assignment Brief and Guidance:

Assignment scenario

You work as in-house software developer for Softnet Development Ltd, a software body-shop providing network provisioning
solutions. Your company is part of a collaborative service provisioning development project and your company has won the
contract to design and develop a middleware solution that will interface at the front-end to multiple computer provisioning
interfaces including SOAP, HTTP, JML and CLI, and the back-end telecom provisioning network via CLI .

Your account manager has assigned you a special role that is to inform your team about designing and implementing abstract
data types. You have been asked to create a presentation for all collaborating partners on how ADTs can be utilised to improve
software design, development and testing. Further, you have been asked to write an introductory report for distribution to all
partners on how to specify abstract data types and algorithms in a formal notation.

Tasks
Part 1

You will need to prepare a presentation on how to create a design specification for data structures, explaining the valid
operations that can be carried out on the structures using the example of:

1. A stack ADT, a concrete data structure for a First In First out (FIFO) queue.
2. Two sorting algorithms.
3. Two searching algorithms.
4. Two network shortest path algorithms.
Part 2

You will need to provide a formal written report that includes the following:

1. Explanation on how to specify an abstract data type using the example of software stack.
2. Explanation of the advantages of encapsulation and information hiding when using an ADT.
3. Discussion of imperative ADTs with regard to object orientation.
Learning Outcomes and Assessment Criteria (Assignment 1)

Pass Merit Distinction

LO1 Examine abstract data types, concrete data structures and


algorithms
D1 Analyse the operation,
P1 Create a design M1 Illustrate, with an example, a using illustrations, of two
specification for data structures concrete data structure for a First network shortest path
explaining the valid operations In First out (FIFO) queue. algorithms, providing an
that can be carried out on the M2 Compare the performance of example of each.
structures. two sorting algorithms.

P2 Determine the operations of


a memory stack and how it is
used to implement function
calls in a computer.

LO2 Specify abstract data types and algorithms in a formal notation

P3 Using an imperative M3 Examine the advantages of D2 Discuss the view that


definition, specify the encapsulation and information imperative ADTs are a basis
abstract data type for a hiding when using an ADT. for object orientation and,
software stack. with justification, state
whether you agree.
Table of Contents
Catalog
Unit 19: Data Structures and Algorithms ASSIGNMENT 1......................................1
ASSIGNMENT 1 ANSWERS.....................................................................1

P1 Create a design specification for data structures explaining the valid operations that
can be carried out on the structures......................................................1
I. Introduction to Abstract Data Type ( ADT ).........................................1
I.I What is ADT?..................................................................1
I.II The benifits of ADT..........................................................1
I.III ADT examples................................................................2
I.IV ADT vs OOP...................................................................2
II. Linear Data Structures............................................................3
II.I Definition ..................................................................3
II.II Linked List.................................................................3
II.III Stack......................................................................3
II.IV Queue.......................................................................3
III. Sorting Algorithms...............................................................3
IV. Searching Algorithms..............................................................3
P2 Determine the operations of a memory stack and how it is used to implement function
calls in a computer.......................................................................4
P3 Using an imperative definition, specify the abstract data type for a software stack....4
REFERENCES...............................................................................4
ASSIGNMENT 1 ANSWERS
P1 Create a design specification for data structures
explaining the valid operations that can be carried out on the
structures.

1. Introduction to Abstract Data Type ( ADT )

1.1 What is ADT?

An abstract data type is an abstraction of a data structure that provides


only the interface to which the data structure must adhere. The interface does not
give any specific details about something should be implemented or in what
programming language. Abstract data types are entities that are definitions of data
and operations but have no implementation details.

Figure I Abstract Data Type

1.2 The benifits of ADT

 ADT is robust and reusable.


 It is based on the principles of Object-Oriented Programming (OOP) and Software
Engineering (SE).
 An ADT can be re-used at several places, and it reduces the coding efforts
 ADT ensures a robust data structure
 Allows better conceptualisation and modelling of the real world.

Page | 1
1.3 ADT examples

List ADT: The data is generally stored in key sequence in a list which has a
head structure consisting of count, pointers and address of compare function needed
to compare the data in the list.
The List ADT Functions is given below:
 get() – Return an element from the list at any given position.
 insert() – Insert an element at any position of the list.
 remove() – Remove the first occurrence of any element from a non-empty list.
 removeAt() – Remove the element at a specified location from a non-empty list.
 replace() – Replace an element at any position by another element.
 size() – Return the number of elements in the list.
 isEmpty() – Return true if the list is empty, otherwise return false.

 isFull() – Return true if the list is full, otherwise return false.

1.4 ADT vs OOP

ADT OOP
Abstract data type is abstraction that It is a self-contained component which
define set of values and set of consists of methods and properties to
operations on these values. make certain type of data useful.
User-defined data type. It is an instance of class.
ADT is made of with primitive datatypes. An object is an abstract data type with
the addition of polymorphism and
inheritance.
It is a type (or class) for objects It is a basic unit of Object-Oriented
whose behaviour is defined by a set of Programming.
value and a set of operations.
Abstract datatype is not necessarily an Objects is an OOP concept.
OOP concept.
Common examples include lists, stacks, Objects have states and behaviours
sets, etc. Test t = new Test();.
Allocate memory when data is stored. When we instantiate an object then

Page | 2
memory is allocated.

2 Linear Data Structures

2.1 Definition

A linear data structure has data elements connected to each other so that elements
are arranged in a sequential manner and each element is connected to the element in
front of it and behind it. This way, the structure can be traversed in a single
run.

There are four of linear data structures:

2.2 Array

An array is a collection of the same data types stored ad contiguous memory


location.

2.3 Linked List


2.3.1 Definition

A linked list is a linear data structure in which elements are linked using
pointers. It consists of nodes where each node contains a data field and a
reference(link) to the next node in the list.

2.3.2 Basic operations on Linked Lists

 Traversal: To traverse all the nodes one after another.

 Insertion: To add a node at the given position.

 Deletion: To delete a node.

Page | 3
 Searching: To search an element(s) by value.

 Updating: To update a node.

 Sorting: To arrange nodes in a linked list in a specific order.

https://www.programiz.com/dsa/linked-list-operations

2.4 Stack

2.4.1 Definition

A stack is linear data structure that stores data elements in a Last-In/First-


Out(LIFO) or First-In/Last-Out (FILO) orther.

2.4.2 Basic operations in stack

 Push: Add an element to the top of a stack

 Pop: Remove an element from the top of a stack

 IsEmpty: Check if the stack is empty

 IsFull: Check if the stack is full

 Peek: Get the value of the top element without removing it

https://www.tutorialspoint.com/data_structures_algorithms/stack_algorithm.htm

2.5 Queue

2.5.1 Definition

A queue is defined as a linear data structure that is open at both ends and

Page | 4
the operations are performed in First In First Out (FIFO) order.

2.5.2 Basic operations in queue

 Enqueue: Insertion of elements to the queue.

 Dequeue: Removal of elements from the queue.

 Peek: Acquires the data element available at the front node of the queue without
deleting it.

 isFull: Validates if the queue is full.

 isNull: Checks if the queue is empty.

https://www.geeksforgeeks.org/queue-data-structure/

3 Sorting Algorithms

3.1 Defiition

A Sorting Algorithm is used to rearrange a given array or list of elements according


to a comparison operator on the elements. The comparison operator is used to decide the new
order of elements in the respective data structure.
https://www.geeksforgeeks.org/sorting-algorithms/

3.2 Common sorthing algorithms

1 Selection Sort Selection sort is a sorting algorithm that selects


the smallest element from an unsorted list in each
iteration and places that element at the beginning of
Page | 5
the unsorted list.
2 Bubble Sort Bubble Sort is the simplest sorting algorithm that
works by repeatedly swapping the adjacent elements if
they are in the wrong order.
3 Insertion Sort Insertion sort is a simple sorting algorithm that
works similar to the way you sort playing cards in
your hands.
4 Merge Sort The Merge Sort algorithm is a sorting algorithm that
is based on the Divide and Conquer paradigm.
5 Quick Sort QuickSort is a Divide and Conquer algorithm. It picks
an element as a pivot and partitions the given array
around the picked pivot.
6 Heap Sort Heap sort is a comparison-based sorting technique
based on Binary Heap data structure.

3.3 Demonstrate two sorthing algorithms

3.3.1 Bubble sort

Bubble sort starts with very first two elements, comparing them to check which one
is greater.

In this case, value of 3 is less than 5, so we swap the value 3 with the value 5.
Next, we compare 5 with 8.

The process is repeated until all values are in their correct places.

Page | 6
https://viblo.asia/p/thuat-toan-sap-xep-noi-bot-bubble-sort-m68Z0exQlkG

3.2.1 Merge sort

4 Searching Algorithms

Searching Algorithms are designed to check for an element or retrieve an element


from any data structure where it is stored. Based on the type of search operation, these
algorithms are generally classified into two categories:

 Sequential Search

 Interval Search

Page | 7
P2 Determine the operations of a memory stack and how it is
used to implement function calls in a computer.
1 Definition
Stacks in Computer Memory are linear data structures (locations) used to store data
in a computer's memory. They may also be referred to as queues. Data within a stack must
always be of the same type.

2 The operations of a memory stack


There are two operations of the stack they are:

 PUSH operation: refers to inserting an element in the stack. Since there’s only one
position at which the new element can be inserted — Top of the stack, the new element is
inserted at the top of the stack.

 POP operation: refers to the removal of an element. Only has access to the element at
Page | 8
the top of the stack, so only a single element can be deleted. So only delete the top
part of the stack.

 Peek operation allows the user to see the element on the top of the stack. The stack is
not modified in any manner in this operation.

 isEmpty: Check if stack is empty or not To prevent performing operations on an empty


stack, the programmer is required to internally maintain the size of the stack which
will be updated during push and pop operations accordingly.

P3 Using an imperative definition, specify the abstract data


type for a software stack.

REFERENCES

Page | 9
Harvard Reference List Citations for Books:
Last name, First initial. and Last name, First initial. (Year published). Title. City:
Publisher, Page(s).
Examples:
 Desikan, S. and Ramesh, G. (2006). Software testing. Bangalore, India: Dorling
Kindersley, p.156
 Daniels, K., Patterson, G. and Dunston, Y. (2014). The ultimate student
teaching guide. 2nd ed. Los Angeles: SAGE Publications, pp.145-151

Harvard Reference List Citations for Websites


Last name, First initial (Year published). Page title. [online] Website name. Available
at: URL [Accessed Day Mo. Year].
Website name, (Year published). Page title. [online] Available at: URL [Accessed Day
Mo. Year].

Examples:

 Messer, L. (2015). 'Fancy Nancy' Optioned by Disney Junior. [online] ABC News.


Available at: http://abcnews.go.com/Entertainment/fancy-nancy-optioned-disney-
junior-2017/story?id=29942496#.VRWbWJwmbs0.twitter [Accessed 31 Mar. 2015].
 Mms.com, (2015). M&M'S Official Website. [online] Available at:
http://www.mms.com/ [Accessed 20 Apr. 2015].

P a g e | 10

You might also like