Docsity

Data Structures and Algorithms: Design Specification for Software Stacks, Study notes of Data Structures and Algorithms

Partial preview of the text

Download Data Structures and Algorithms: Design Specification for Software Stacks and more Study notes Data Structures and Algorithms in PDF only on Docsity!

ASSIGNMENT 1

Data Structures &

Algorithms

Student Name: Phan Hoa An Khe

Student ID: GCS

Class: GCS1003A

Subject Code: 164 9

Assessor Name: Le Ngoc Thanh

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 Phan Hoa An Khe Student ID GCS 210040 Class GCS1003A Assessor name Le Ngoc Thanh 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 D

ASSIGNMENT BRIEF 1 (RQF)

Higher National Certificate/Diploma in Business

Student Name/ID Number: Phan Hoa An Khe / GCS Unit Number and Title: Unit 19: Data Structures and Algorithms Academic Year: 2021 Unit Assessor: LE NGOC THANH Assignment Title: Examine and specify ADT and DSA Issue Date: Submission Date: Internal Verifier Name: 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 frontend 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 network shortest path algorithms. Part 2 You will need to provide a formal written report that includes the following:
  4. Explanation on how to specify an abstract data type using the example of software stack.
  5. Explanation of the advantages of encapsulation and information hiding when using an ADT.
  6. Discussion of imperative ADTs with regard to object orientation. Learning Outcomes and Assessment Criteria (Assignment 1) Pass Merit Distinction

Contents

  • carried out on the structures (P1) 1. Create a design specification for data structures explaining the valid operations that can be
    • 1.1. Data Structure
    • 1.2. Why are data structures are important?
    • 1.3. Characteristics of data structures
    • 1.4. Types of Data Structure
    • 1.5. Linear data structures
      • 1.5.1. Array Data Structure
      • 1.5.2. Queue Data Structure
      • 1.5.3. Linked List Data Structure
      • 1.5.4. Stack Data Structure....................................................................................................
    • 1.6. Non linear data structures
      • 1.6.1. Graph Data Structure
      • 1.6.2. Trees Data Structure....................................................................................................
  • computer (P2)................................................................................................................................ 2. Determine the operations of a memory stack and how it is used to implement function calls in a
    • 2.1. Memory Stack
    • 2.2. LIFO
    • 2.4. How a computer uses it to implement function calls?
    1. Using an imperative definition, specify the abstract data type for a software stack (P3)
    • 3.1. Software Stack
  • Reference

Figures Figure 1: Data Structure Illutration ( Source: https://www.geeksforgeeks.org/data-structures/ ) .. 9 Figure 2: Array Data Structure Illutration ( Source: https://www.programiz.com/dsa/data- structure-types ) ............................................................................................................................ 11 Figure 3: Queue Data Structure Illustration ( Source: https://www.programiz.com/dsa/data- structure-types ) ............................................................................................................................ 12 Figure 4: Example of Queue Data Structure ................................................................................. 13 Figure 5: Linked List Data ............................................................................................................ 13 Figure 6: Stack Data Structure Illustration ( Source: https://www.programiz.com/dsa/data- structure-types ) ............................................................................................................................ 14 Figure 7: Graph Data Illusration ( Source: https://www.programiz.com/dsa/data-structure-types) ....................................................................................................................................................... 15 Figure 8: Example of grapgh data ( Source: https://www.programiz.com/dsa/graph ) ................ 16 Figure 9: Trees Data Structure Illustration ( Source: https://www.programiz.com/dsa/data- structure-types ) ............................................................................................................................ 17 Figure 10: Edge ............................................................................................................................. 18 Figure 11: Height of a Tree ........................................................................................................... 19 Figure 12: Forest ........................................................................................................................... 19 Figure 13: Memory Stack Illustration ........................................................................................... 20 Figure 14: Example of Memory Stack ( Source: https://www.sciencedirect.com/topics/engineering/stack-memory ) ............................................ 21 Figure 15: Memory Stack call function ( Source: Function Calls and the Call Stack — Programming and Data Structures 0.2 documentation (eecs280staff.github.io) ) ........................ 22 Figure 16: a stack that increases in depth rather than height ( Source: Function Calls and the Call Stack — Programming and Data Structures 0.2 documentation (eecs280staff.github.io) ) ......... 22 Figure 17: Activation record for a pass-by-reference function ( Source: Function Calls and the Call Stack — Programming and Data Structures 0.2 documentation (eecs280staff.github.io) ) ......... 23 Figure 18: Memory Stack ............................................................................................................. 23 Figure 19: LIFO Illustration .......................................................................................................... 24 Figure 20: Software Stack (Source: https://www.geeksforgeeks.org/what-is-software-stack/) ... 25 Figure 21: Example of Software Stack ( Source: www.techtarget.com ) ..................................... 28

    1. Why are data structures are important? Most computer programming languages' standard base data types, such as integers or floating- point numbers, are typically insufficient to convey the logical intent for data processing and application. Yet, in order to make processing easier, applications that consume, manipulate, and output information need to be aware of how data should be arranged. Data structures enable the efficient usage, persistence, and sharing of data by logically combining the data parts. They offer a formal model that outlines the arrangement of the data items. Data structures serve as the foundation for more complex applications. In order to create them, data components are combined into logical units that reflect abstract data types relevant to the algorithm or application. A "customer name," which consists of the character strings for "first name," "middle name," and "last name," is an illustration of an abstract data type.
    1. Characteristics of data structures
  • Linear or non-linear
  • Homogeneous or heterogeneous
  • Static or dynamic Linear or non-linear This attribute specifies whether the data pieces are organised in an unordered or sequential order, such as using a graph or an array.
  • Linear data structure: A linear data structure is one in which the elements of the data are ordered consecutively or linearly, with each element being connected to its immediately preceding and following neighboring elements.
  • Static data structure: Data structures that are static have a fixed amount of memory. A static data structure's elements are simpler to access. An array is a kind of this data structure.
  • Dynamic data structure: The size of a dynamic data structure is variable. It can be randomly updated while the program is running, which is thought to be efficient given the code's memory (and space) complexity. Queue, stack, and other such data structures are examples.
  • Non-linear data structure: Non-linear data structures are those in which the placement of data items is not linear or sequential. We cannot explore every element of a non-linear data structure in a single operation. Trees and graphs are two examples of non-linear data structures. The array data structure, for instance, can be used to store a list of items with the same data type. Homogeneous or heterogeneous This attribute indicates if every data item in a specific repository belongs to the same type. An array of items or a collection of different types, such as an abstract data type described as a structure in C or a class specification in Java, are two examples.

Static or dynamic This characteristic explains the compilation process for the data structures. At the moment of compilation, static data structures have fixed sizes, structures, and memory locations. Depending on their application, dynamic data structures' sizes, structures, and memory locations might change.

    1. Types of Data Structure Essentially, there are two classifications for data structures:
  • Linear data structure
  • Non-linear data structure 1.5. Linear data structures The elements are placed sequentially, one after the other, in linear data structures. The elements are simple to use because they are set up in a specific order. However, because of operational difficulties, linear data structures might not be the ideal option when program complexity rises. These are common linear data structures:
  • Array Data Structure
  • Queue Data Structure
  • Linked List Data Structure
  • Stack Data Structure
  1. 5 .1. Array Data Structure The elements in memory are organized in a continuous memory in an array. An array's items are all of the same type. Moreover, the programming language affects the kind of elements that can be stored as arrays. Figure 2 : Array Data Structure Illutration ( Source: https://www.programiz.com/dsa/data- structure-types )

Figure 4 : Example of Queue Data Structure Applications of Queue

  • Disk scheduling and CPU planning
  • When information is sent between two processes asynchronously.
  • Synchronization takes place in the queue. An illustration would be IO Buffers, Pipes, File IO, etc.
  • Interrupt management in real-time systems.
  • To keep persons who are phoning call centers in order, call center phone systems use queues. 1. 5 .3. Linked List Data Structure Data components in a linked list data structure are linked together by a number of nodes. Also, each node has an address for the node behind it as well as data elements. A linear data structure called a linked list has a number of connected nodes. Each node keeps the data and the address of the node after it here. Figure 5 : Linked List Data Applications of Linked Lists
  • Allocating memory dynamically
  • Implemented in queues and stacks
  • In software's undo functionality
  • Graphs and hash tables
      1. Stack Data Structure Figure 6 : Stack Data Structure Illustration ( Source: https://www.programiz.com/dsa/data- structure-types ) The LIFO technique is used to store elements in stack data structures. In other words, the last element in a stack will be taken out first. An abstract data type (ADT) is a mathematical representation of a data type in computer science. In terms of possible values, operations that could be performed on this type of data, and the behavior of those actions, an abstract data type is characterized by its behavior (semantics) from the perspective of a user. Data structures, which are physical representations of data and are viewed from the perspective of an implementer rather than a consumer, contrast this mathematical paradigm. Instead of storing data in each node, the Stack ADT Implementation stores a pointer to the data. The address is provided to the stack ADT and the software allots memory for the data. The ADT contains both the head node and the data nodes. The only thing the calling function can see is the stack pointer. A pointer to the top and a count of how many elements are currently in the stack are also included in the stack head structure.

Figure 8 : Example of grapgh data ( Source: https://www.programiz.com/dsa/graph ) Graph Terminology

  • Adjacency: If there is an edge connecting two vertices, they are said to be next to one another. Due to the lack of an edge between them, vertices 2 and 3 are not close by.
  • Path: A path is a collection of edges that connects vertex A and vertex B. The pathways from vertex 0 to vertex 2 are 0-1, 1-2, and 0-2.
  • Directed Graph: An edge (u,v) on a directed graph does not always imply that there is an edge (v,u) as well. With this type of graph, the edges are shown as arrows to indicate their orientation.
      1. Trees Data Structure Figure 9 : Trees Data Structure Illustration ( Source: https://www.programiz.com/dsa/data- structure-types ) Other linear data structures that store data sequentially include arrays, linked lists, stacks, and queues. Any operation in a linear data structure requires more time to complete as the size of the data increases. But, in the world of computation today, it is unacceptable. As a non-linear data structure, different tree data structures make it possible to access the data more quickly and simply. Tree Terminologies
  • Node
  • Edge
  • Root
  • Height of a Node
  • Depth of a Node
  • Height of a Tree
  • Degree of a Node
  • Forest

Figure 11 : Height of a Tree 1.6.2.7. Degree of a Node The total number of branches at a node determines its degree. 1.6.2.8. Forest A forest is a group of randomly placed trees. Figure 12 : Forest

  1. Determine the operations of a memory stack and how it is used to implement function calls in a computer (P2) 2.1. Memory Stack Figure 13 : Memory Stack Illustration A linear data structure (location) called a memory stack is used to store data in a computer's memory. They can also be referred to as lines. The stack's data must always include the same type of data. A stack's items are added or removed in a linear order rather than at random. The data pieces in the stack are stored and accessed in a specific manner, just like in any queue or aggregate. In this instance, the LIFO (first in, first out) method is utilized. By converting a section of the computer's memory to a stack operation and using a processor register as a stack pointer, a stack can be executed in the CPU. This approach executes it in a CPU- connected random access memory.