Docsity

1649-Assignment 1-Data Structure, Assignments of Data Structures and Algorithms

Partial preview of the text

Download 1649-Assignment 1-Data Structure and more Assignments Data Structures and Algorithms in PDF only on Docsity!

Higher NaƟonals in CompuƟng

Advanced Programming

Assignment 1

Student’s name: AU LAM THANH DAT

ID: GCS

Class: GCS1003B

Subject code: 1649

Assessor name: LE NGOC THANH

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 Student ID Class Assessor name 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: Unit Number and Title: Unit 19: Data Structures and Algorithms Academic Year: 2021 Unit Assessor: 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 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 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.

Table of Contents

  • on the structures (P1) I. Create a design specification for data structures explaining the valid operations that can be carried out
      1. Abstract data type (ADT).......................................................................................................................
      1. Examples:
      • 2.1. Stack ADT
      • 2.2. Queue ADT
  • computer(P2) II. Determine the operations of a memory stack and how it is used to implement function calls in a
      1. Definition of Stack Memory
      1. The Operations of memory stack........................................................................................................
      1. How stack used to implement function calls
  • III. The abstract data type for a software stack(P3)
      1. Definition
      1. Example of software stacks.................................................................................................................
      1. Conclusion
  • References

I. Create a design specification for data

structures explaining the valid operations

that can be carried out on the structures

(P1)

1. Abstract data type (ADT)

An object's behavior may be described by a set of values and a set of actions, and this behavior is known as an abstract data type (ADT). The definition of ADT merely specifies which operations must be carried out; it makes no reference of how they must be carried out. It does not describe how the operations will be carried out or how the data in memory will be arranged. Given that it offers a dispassionate view of the implementation, it is dubbed "abstract." Abstraction is the process of presenting only the essentials while obfuscating the information. Figure 1: ADT Features of ADT:

  • Abstraction: It is not necessary for the user to understand how the data structure is put together.
  • Better Conceptualization: ADT helps us grasp the real world better.
  • Robust: The software is capable of spotting errors and is robust.

Some operations of stack: Push(): Insert an element named top at one end of the stack. Pop(), Peek(): The item at the top of the stack should be removed and returned. Return the element at the top of the stack without deleting it if the stack is not empty. Size(): Give back the number of items in the stack. Empty(): If the stack is empty return true, otherwise return false. isFull(): If the stack is full, return true, otherwise return false. Push(): add one item on the top of the stack. Five step to work push(): Step 1: Review for full row Step 2: The error happen until the stack complete, and exit. Step 3: Increases top to point next empty space, if the stack is not full. Step 4: Adds the data element to the location of the stack, where top is pointing Step 5: Performance returns. Figure 3: Push Operation

Pop (): Remove the top item out of the stack. Five step to work pop (): Step 1 - Checks if the stack is empty. Step 2 − If the stack is empty, produces an error and exit. Step 3 − If the stack is not empty, accesses the data element at which top is poinƟng. Step 4 − Decreases the value of top by 1. Step 5 − Returns success. Figure 4: Pop Operation  Application/Examples of Stack: Figure 5: Example of Stack

 Queue operation: Operation Description Clear() Check to clear the queue isEmpty() Check the queue is empty or not empty Enqueue() Add new element at the end of queue Dequeue() Remove first element of the queue Front() Return first element without remove Table 2: Queue Operation  Example for queue: Operation Output Input Enqueue(1) (1) Enqueue(2) (1, 2) Dequeue(1) 1 (2) Enqueue(4) (2, 4) Front() 4 (1, 4) Dequeue(2) 2 (4) Dequeue(4) 4 () Dequeue() Error () isEmpty() True () Enqueue(9) (9) Size() 1 Table 3: Example of queue

II. Determine the operations of a memory

stack and how it is used to implement

function calls in a computer(P2)

1. Definition of Stack Memory

The first-in-last-out buffer-like behavior of stack memory makes it possible to employ system memory for temporary data storage. It serves as a short-term memory. The memory of the variable is automatically cleared when the computation is finished. Most of the time, methods, local variables, and reference variables are found in the stack section.

Basic Operations of Stack:

  • Push: Placing a component on top of a stack.
  • Pop: To remove a stack's top element.
  • IsEmpty: Verifying whether the stack is empty.
  • IsFull: determining whether the stack is full.
  • Peek: Obtaining the top element's value without removing it.
  1. The Operations of memory stack Linear data structures (locations) called memory stacks are used to store data in a computer's memory. They might alternatively be called lines. Always have the same kind of data in a stack. Figure 7: Memory Stack Pop operation: Removing an element is referred to as a pop operation. There is only one element that can be removed since we can only access the element at the top of the stack. Just the top of the stack is removed. PEEK Operation: The user can view the element at the top of the stack using the peek operation. No changes are made to the stack during this process. Push operation: The act of pushing data onto a stack is referred to as a push operation. isEmpty: Determine if the stack is empty or not. The programmer must internally maintain the size of the stack, which will be updated throughout push and pop operations, in order to prevent conducting actions on an empty stack. Normally, the boolean result returned by the function isEmpty() True if size equals 0, else False.

 When a function call executes, the activation recording for that call is placed onto the stack of the program being executed.  When the function returns to its caller and the local variables are no longer known to the execution program, the activation record for this function call is popped off the stack.  The last function call on the stack is returned when getting the necessary function calls since it is the stack's top element, and any subsequent function calls will be made to that function as long as there is still another function on the stack that needs to be called.

III. The abstract data type for a software

stack(P3)

1. Definition

The execution of an application is supported by a stack of separate software components that cooperate. The components are placed one on top of the other in a hierarchy and may comprise an operating system, architectural layers, protocols, runtime environments, databases, and function calls. Higher-level components execute specialized duties and services for the end user, whereas lower-level components in the hierarchy often interface with hardware. A sequence of intricate instructions that traverse the stack are used by components to directly connect with the application. Figure11: Software Stack

In order to offer certain services to the user, an application is made up of a number of functions that work together in a predetermined architecture. There are three levels in the simplest application architecture:

  • When a consumer accesses the program through a website or web-based application portal, they view the presentation layer.
  • The logic layer consists of business rules and application logic that help fulfill application requests. This layer controls data transit between the data layer and the display layer, performs computations, and makes decisions regarding how to handle requests.
  • When a computation is required or if it has to be transferred to a user-visible presentation layer, the data layer, a server-side system, sends information from the logic layer. Software stacks provide a number of benefits, including the potential to offer predefined solutions to problems, which are occasionally the best ones.  They just provide the absolute minimum of software necessary to achieve the intended outcomes.  Software stacks can be set up manually in computer templates or automatically in systems.  For customisable systems, software stack installation and use are same. As a consequence, the solutions provided are also reliable.  The vast majority of software stacks are capable of supporting the entire package. Some also provide community forums.  Software stacks can be installed using an image or software specs. Some functions can only yield the desired outcome if specific circumstances are met when the function is called. Only input set limits for standalone functions that don't have an impact on permanent data are relevant to such situations. For operations on a data structure, even the network's present state may need to be taken into consideration. Those requirements are necessary before invoking a feature.
  1. Conclusion I have acquired a lot of new, crucial information since finishing this report, most of it that I was previously unaware of. I will be able to prepare for my classes in the future with more efficiency because to my improved grasp of data structures and algorithms. I want to thank my professors most of all for their passionate advice and assistance.

References

  1. What is stack data structure? (no date) Studytonight.com. Available at: https://www.studytonight.com/data-structures/stack-data-structure (Accessed: February 28, 2023).
  2. Abstract data types (2022) GeeksforGeeks. GeeksforGeeks. Available at: https://www.geeksforgeeks.org/abstract-data-types/ (Accessed: February 28, 2023).
  3. Algorithms 10: Abstract data types – stack (no date) Sign in or register. Available at: https://learn1.open.ac.uk/mod/oublog/viewpost.php?post=162582 (Accessed: February 28, 2023).
  4. Data Structure and algorithms - stack (no date) Tutorials Point. Available at: https://www.tutorialspoint.com/data_structures_algorithms/stack_algorithm.htm (Accessed: February 28, 2023).
  5. Abstract data type in data structures tutorial 28 February 2023 - learn abstract data type in data structures tutorial (7124): Wisdom Jobs India (no date) Wisdom Jobs. Available at: https://www.wisdomjobs.com/e-university/data-structures-tutorial-290/abstract-data-type- 7124.html (Accessed: February 28, 2023).
  6. What is software stack (2021) GeeksforGeeks. GeeksforGeeks. Available at: https://www.geeksforgeeks.org/what-is-software-stack/ (Accessed: February 28, 2023).
  7. Semilof, M. and Montgomery, J. (2020) What is a software stack?, App Architecture. TechTarget. Available at: https://www.techtarget.com/searchapparchitecture/definition/software-stack (Accessed: February 28, 2023).
  8. What is cloud computing? A beginner's guide: Microsoft azure (no date) What Is Cloud Computing? A Beginner's Guide | Microsoft Azure. Available at: https://azure.microsoft.com/en-us/resources/cloud-computing-dictionary/what-is-cloud- computing/ (Accessed: February 28, 2023).
  9. What is multicore? - definition from Techopedia (no date) Techopedia.com. Available at: https://www.techopedia.com/definition/5305/multicore (Accessed: February 28, 2023).
  10. Function calls and the call stack¶ (no date) Function Calls and the Call Stack - Programming and Data Structures 0.2 documentation. Available at: https://eecs280staff.github.io/notes/02_ProceduralAbstraction_Testing.html (Accessed: February 28, 2023).