Professional Documents
Culture Documents
Unit number and title Unit 19: Data Structures and Algorithms
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:
IV Signature:
TABLE OF CONTENTS
I. Introduction______________________________________________________________________________4
1. Scenario_________________________________________________________________________________4
2. Report___________________________________________________________________________________4
II. Data structures:__________________________________________________________________________5
1. Data structures____________________________________________________________________________5
2. Abstract data types_________________________________________________________________________5
a. Definition :_______________________________________________________________________________5
b. Example of ADT__________________________________________________________________________7
III. ADT usages___________________________________________________________________________11
1. Application of Stack in memory_____________________________________________________________11
2. Application of an ADT:____________________________________________________________________19
IV. Conclusion____________________________________________________________________________23
TABLE OF FIGURES
I. Introduction
1. Scenario
As part of a service delivery partnership project, SoftNet Development Ltd, a software firm that supplies
networking solutions, has hired my company to create and install a middleware solution that would front
end with a number of interfaces. The computer delivery interface can be used to communicate with the
back-end telecommunications service network using CLI, in addition to SOAP, HTTP, JML, and other
protocols.
My account manager has entrusted me with the special duty of educating my team on the development and
application of abstract data types. I was asked to give a presentation to all of the working partners on how
to use ADT to improve software design, development, and testing. All partners needed to receive the formal
specification of abstract data types and techniques, so I also had to write an introduction report.
2. Report
I'll demonstrate how to write a design specification for a data structure and how to enumerate the legal
operations that may be carried out on the structure.
How are abstract data types supposed to be defined?
What advantages information encapsulation and hiding have when used with ADT?
What ADTs are necessary for object orientation?
Single-linked list is one of the most fundamental data structures you will learn in this course. A
value and, if any, a reference to the node that comes after it in the list make up each node in this
singly linked list.
It is the most basic kind of linked list in which each node contains a pointer to the node immediately
following it, which also contains some data of the same type.
When a node claims to have a reference to the node following it in the sequence, it actually
indicates that it retains the address of that node. Data can only be traversed once in a single linked
list. The similar image is shown below.
Representation of Singly-linked Lists:
A pointer to the list's first node serves as the representation of a linked list. The linked list's
head is represented by the first node. The value of the head points to NULL if the linked list
is empty.
An indication (store with integers, strings, or any type of data).
a node address or a reference (or pointer) to the node after that (which joins one node
to another).
Implement SinglyLinkedList in Java:
Figures 2. SinglyLinkedList code 1
Figures 6. SinglyLinkedList
Explan code: when I use method addFirst(), number will add to mySinglyLinkedList and the next I use method
addLast() to add number behind the list and display them. I use removeLast to remove number the last in list but
before remove, I setting method to display number on screen before delete and I call list of number again to show
the list after delete number.
Adding data to the stack with the PUSH instruction is known as pushing, and removing data from the stack is
known as popping. Depending on the CPU architecture, some processors use incremental address indexing while
others use decrement address indexing when adding new data to stack memory. The stack operation in Cortex-M
processors is built on the "full-descending" stack concept. As a result, the stack pointer shrinks with each new data
storage and always links to the stack memory's most recently filled data.
PUSH and POP are frequently used at the start and end, respectively, of a function or subroutine. The caller
program's current register values are first momentarily stored on the stack memory using PUSH operations. The
data in the stack memory is then returned to the registers at the function's conclusion using POP operations. The
stack pointer won't be able to reset registers to their default values if there isn't a register POP action for each
register PUSH operation. This could result in unexpected behavior because the function might return to the wrong
addresses.
Features of Stack:
A stack is an ordered collection of objects of a same type. an array used to hold strings or integers, for
instance.
The basis of this system is FILO (First-In-Last-Out) or LIFO (Last-In-First-Out) features.
When a stack is entirely full, it is said to be in the overflow state, and when it is entirely empty, it is said
to be in the underflow state.
How to Stack in DataStructure ?
A stack is a very simple data structure that can only perform the two operations Push and Pop. These actions help
explain how the stack functions as a data structure. As they are each individually detailed below, let's look at them
one at a time. Let's look at the insertion and deletion (removal) operations in a stack that are covered below.
Insertion Operation
When an element is added to a data structure, a push operation occurs. As an object is pushed into a pit, an element
that is added to a stack falls to the bottom. Each ingredient is added one after the other, with the next one coming
after the previous one. Every time an insertion operation—also referred to as a "posh operation"—takes place, one
element is placed into the stack. We shall understand how push operations work by the actions that follow.
Think about the following five figures: 39, 38, 2022, and 4. To store these pieces in memory, we'll employ a stack
data structure. The parts have to be stacked in that particular sequence. The push operation will proceed in this case
as detailed below.
At first, as seen in the illustration below, the stack is empty. The push operation will be used to add each element to
this stack.
The second, I add 39 initially inserted into the stack using the push operation, taking up the bottommost
position.
Lastly, The push() operation is used to add element 38, 2022, 4, as shown below, as the following element
to be added to the stack. The stack then becomes full after the last element is added. This is depicted as
follows.
Figures 4. Illustration (3)
We shall understand the deletion operation in the stack by using the illustration from the insertion operation
section. starting with the last deed in the prior section We are aware of this now that the stack is full. The stack's
elements will all be removed at once. Taking an element out of the stack is done by the "Pop" action. The first step
of the pop operation is to remove the most recent element to be added. The removal action in the stack will
function as described below and will be enabled by the pop operation.
A function is a section of code that may be invoked anytime a certain job has to be performed. To properly employ
numerous function calls or recursion and to better understand the code, it is necessary to appreciate the concept of
a function call. Understanding how function calls operate requires some prior knowledge of CPU program
execution, program stacks, and stack frames (Activation Record).
Program Stack: The main functions are the items at the bottom of the program stack, which is made up of
all function calls.
Stack Frame: The data from the called function is contained in a "Stack Frame," a component of the
program stack. Some of that is :
Return Address
Input Parameter
Local Variables
Register Savings
Stack pointer: The stack Pointer, which is a pointer to the top of the program stack, indicates the most
recent function that was called.
The freshly constructed stack frame that is pushed into the program stack each time a function is called has
replaced the stack pointer, which previously always pointed to the top of the program stack. The data for the called
function is all contained in this stack frame.
The POP instruction in assembly language removes the top of the stack and assigns it to the program counter.
Figures 5. Array(2)
Figures 6. Array(3)
Figures 7. Array(4)
Figures 9. Result
IV. Conclusion
In this report, I covered abstract data types, how to build data structure design specifications, and a sample that
explains the legitimate operations that may be done with the structure's data that is set aside for the First In First
Out (FIFO) queue. This paper has been revised to discuss the advantages of information hiding and encapsulation
when utilizing ADTs as well as the ADTs required for object orientation. In addition, this study serves as the basis
for my next report.
References
Anon., 2012. What is ADT? (Abstract Data Type). [Online]
Available at: https://stackoverflow.com/questions/10267084/what-is-adt-abstract-data-type
[Accessed 5 12 2022].