Higher Nationals in Computing Unit 19: Data Structures and Algorithms ASSIGNMENT 1 Student’s name: HA CAO MINH DANG Assessor name: Class: GCS0903A Student ID: GCS200837 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 Ha Cao Minh Dang Student ID GCS200837 Class GCS0903A 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 D2 Summative Feedback: Grade: Resubmission Feedback: Assessor Signature: Internal Verifier’s Comments: IV Signature: Date: Assignment Brief 1 (RQF) Higher National Certificate/Diploma in Business Student Name/ID Number: Ha Cao Minh Dang/GCS200837 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: 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 P1 Create a design specification for data structures explaining the valid operations that can be carried out on the structures. M1 Illustrate, with an example, a concrete data structure for a First In First out (FIFO) queue. M2 Compare the performance of two sorting algorithms. D1 Analyse the operation, using illustrations, of two network shortest path algorithms, providing an example of each. 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 definition, specify the abstract data type for a software stack. M3 Examine the advantages of encapsulation and information hiding when using an ADT. D2 Discuss the view that imperative ADTs are a basis for object orientation and, with justification, state whether you agree. Table of Contents Unit 19: ......................................................................................................................................................................... 1 Data Structures and Algorithms .................................................................................................................................... 1 ASSIGNMENT 1.......................................................................................................................................................... 1 Assignment Brief 1 (RQF) ............................................................................................................................................ 4 Higher National Certificate/Diploma in Business .................................................................................................... 4 P1 Create a design specification for data structures explaining the valid operations that can be carried out on the structures. ........................................................................................................................................................................ 8 Data Structure .............................................................................................................................................................. 8 Types of data structures ............................................................................................................................................ 8 Pros and cons of data structures ................................................................................................................................ 9 Stack operations and working mechanism:............................................................................................................... 9 P2 Determine the operations of a memory stack and how it is used to implement function calls in a computer. ...... 10 Memory Stack:........................................................................................................................................................ 10 Operations ............................................................................................................................................................... 11 Exception ................................................................................................................................................................ 12 Application: ............................................................................................................................................................ 12 Implement Stack by Array in Java: ......................................................................................................................... 13 P3. Using an imperative definition, specify the abstract data type for a software stack. ............................................ 14 Definition of software stack: ................................................................................................................................... 14 Parts of a software stack ......................................................................................................................................... 14 Five Software Stack Examples: .............................................................................................................................. 15 References................................................................................................................................................................... 17 P1 Create a design specification for data structures explaining the valid operations that can be carried out on the structures. Data Structure The data structure is a physical representation of a set of data types. The time complexity and memory of the Data Structure can be examined, but not the data type. Data structures can be implemented in a variety of ways, and how they are implemented varies by language. The data structure is a method of organizing data in a computer so that it can be effectively used. A uniform data structure, for example, can be used to store a list of items with the same data type. Two entities are at the heart of every program or piece of software: data and algorithms. Algorithms convert data into something that can be used by a program. Furthermore, data structures are computer programs that improve how the information management process calculates data in memory. Data structures frequently combine to form new structures, which are then applied to a specific data access pattern. The performance of algorithms is greatly improved by selecting the most efficient data structure for the job, which helps to speed up application processing. This enables computer systems to manage massive amounts of data efficiently in large-scale indexing, massive databases, and big data platforms. To put it another way, data structure refers to the various methods for sorting data on your computer. Types of data structures 1. Primitive Data Structures These are machine-level supported structures that can be used to create non-primitive data structures. This is both necessary and pure in appearance. They follow a set of rules and specifications. Integer, Float, Character, and Pointer are just a few examples. A pointer, on the other hand, does not hold a data value; rather, it keeps the memory addresses of data values. This data type is also known as the reference data type. 2. Non-Primitive Data Structures Without the original data structure, non-primitive data structures can be implemented. They are data structures of origin and cannot be formed without using primitive data structures, despite the fact that they are also provided by the system. Simple data structures and compound data structures are the two types of non-primitive data structures. Figure 1: Data structure Pros and cons of data structures 1. Pros - Data structures allow information to be stored on hard drives. - Large datasets, such as databases or internet indexing services, can be managed with this tool. - Allows you to store information on your computer in a secure manner. This data can then be saved for later use and accessed by a variety of programs. Furthermore, the data is secure and should not be lost (especially if it is stored on magnetic tape). - Permitting the use and processing of data on software systems. - Allows for more efficient data processing. - We can access data from any connected machine at any time using the internet (computer, laptop, tablet, phone, etc.) 2. Cons - The data structure can only be changed by sophisticated users. - Any issue involving the data structure necessitates the assistance of a specialist, which is why basic users are unable to assist themselves. Stack operations and working mechanism: Press Operation is the process of adding a new data element to a stack. There are several steps to the minus operation: Step 1: Check whether the stack is full. Step 2: If the stack is full, create an error and exit. Step 3: If the stack is not full, move up to the next empty spot. Step 4: Add the data element to the stack location, where the peak points. Step 5: Return success. The following is a simple algorithm for Push operation.: begin procedure push: stack, data if stack is full return null endif top ← top + 1 stack[top] ← data end procedure P2 Determine the operations of a memory stack and how it is used to implement function calls in a computer. Memory Stack: A stack can be implemented in a computer's random-access memory (RAM). A stack is implemented in the CPU by allocating a chunk of memory to a stack operation and using a processor register as a stack pointer. The stack pointer is a processor register that specifies the stack's starting memory location. Figure 2: Memory stack Operations A Stack is a collection of elements of the same type that are arranged in a logical order. All operations are performed at a single end of the stack, which is the top of the stack, and the following operations are possible: •push() – Inserts a new element at the top of the stack. •pop() – If the stack isn't empty, remove and return the element at the top. •peek() – If the stack is not empty, return the element at the top of the stack without removing it. •size() – Returns the stack's size in elements. •isEmpty() – If the stack is empty, return true; otherwise, return false. •isFull() – If the stack is full, return true; otherwise, return false Exception -The operations pop and top cannot be performed if the stack is empty. -A StackEmptyException should be thrown if you try to execute pop or top on an empty stack. - Due to a lack of memory, push operations are occasionally unable to complete. - When memory is insufficient, attempting to execute push should result in an OutOfMemoryError. Application: Nesting of any kind (such as parentheses) Determining the value of arithmetic expressions (and other sorts of expression) Implementing method or function calls Maintaining a record of previous decisions (as in backtracking) Keeping track of decisions that have yet to be made (as in creating a maze) In a text editor, undo sequence An algorithm's auxiliary data structure Part of a larger data structure Method calls and the implementation by using stack An activation record (AR) is assigned to each method that is called. -The following information is contained in this record: The called method's parameters and local variables Dynamic link: a link to the activation record for the caller Return address to allow the caller to regain control (address of instruction immediately following the call) Value returned by a method that isn't declared as void. Because the size of the AR varies from call to call, the returned value is placed directly above the caller's AR. Each new AR is stacked on top of the previous one. A method's AR is removed from the top of the run-time stack when it terminates. As a result, the first AR on the stack is the last one to be removed. Implement Stack by Array in Java: Output P3. Using an imperative definition, specify the abstract data type for a software stack. Definition of software stack: An application is made up of a set of functions that work together in a defined architecture to provide the user with specific services. Three layers make up the most basic application architecture: Layer of Presentation: When a client accesses an application through a website or web-based application portal, they see the presentation layer. Logic Layer: The logic layer stores application logic and business rules, which aids in the fulfillment of application requests. This layer performs calculations and makes decisions about how to handle requests while supervising data flow between the data layer and the presentation layer. Data Layer: The data layer is a server-side system that sends data to the logic layer when it's time to complete a computation or deliver it to the presentation layer, where users can view it. Each of these layers has its own set of programming languages and software tools that it needs to set up and maintain its functionality. HTML5, JavaScript, and CSS are examples of languages that can be used to create a web-based presentation layer. Java, C#, Python, or C++ could be used to create the application layer. Back-end servers could be maintained using applications like MySQL and MongoDB. The term "Software Stack" refers to the collection of components that work together to support application execution. Some software components are used to power back-end processes, while others are used in the presentation layer to enable user interface. In any case, the components of a software stack work together to deliver application services to the end-user as quickly as possible. Parts of a software stack There are four tiers in an application, three of which are server-side. This diagram depicts how a stack works: the client is where it all begins and ends. •In the browser, the client tier is the only component. •The web tier is comprised of the web server (also known as an HTTP server). •The application server (which includes the development platform, frameworks, and server-side programming languages) is the business tier. •The database tier—the database server you select, which is frequently influenced by the business tier. An operating system, server, database, and server-side scripting language are all included in each tier. You're not restricted to the components in a stack; they're interchangeable and customizable based on your needs. Figure 3: software stack Five Software Stack Examples: Other developers may use a software stack that has proven to be beneficial or preferable for delivering a particular type of application on occasion. A popular software stack may take on a life of its own as an increasing number of software companies choose the same set of software components to create an application. Software companies may bundle and sell specific components as a single software stack for a specific purpose. Five of the most popular software stacks for developers to use as an application platform are listed below: 1. LAMP - LAMP is a web services-oriented software stack that can be used to build dynamic web pages and cloud applications. The stack includes the Linux operating system, Apache web server, MySQL relational database management system, and PHP programming language. 2. To create dynamic websites and web apps, the MEAN software stack is used, which consists of four free and open-source components: a database tool called MongoDB, the Express.js web application server framework, and a front-end web framework called Angular.js, and the Node.js runtime environment. 3. WIMP - The Windows operating system, IIS web servers, MySQL or MS Access for data administration, and PHP, Perl, or Python for programming make up the WIMP software stack. 4. NMP - NMP is a collection of software stacks that include Nginx web servers, MySQL, and PHP programming language. This technology suite has been packaged separately for Linux, Windows, and macOS and is compatible with all major operating systems. 5. MAMP - The MAMP framework allows you to build websites that run on both Windows and Mac computers. The operating system (macOS or Windows), the Apache web server, MySQL for relational database administration, and PHP, Perl, or Python for web programming make up the software stack. Each software stack has its own set of advantages and disadvantages for developers. Before deciding on the best set of software solutions to support the delivery of application services to end-users, application architects must first comprehend and anticipate the application's unique requirements. References 1. objects?, W., 2021. What is the difference between Abstract Data Types and objects?. [online] Computer 2. 3. 4. 5. 6. 7. 8. 9. Science Stack Exchange. Available at: https://cs.stackexchange.com/questions/51847/what-is-the-differencebetween-abstract-data-types-and-objects [Accessed 12 February 2021]. W3schools.com. 2021. Java Encapsulation and Getters and Setters. [online] Available at:<https://www.w3schools.com/java/java_encapsulation.asp> [Accessed 12 February 2021]. Afteracademy.com.2021.Comparison of Sorting Algorithms.[online] Available at:https://afteracademy.com/blog/comparison-of-sorting-algorithms [Accessed 11 February 2021]. Programiz.com.2021.Bellman Ford's Algorithm.[online]Available at :<https://www.programiz.com/dsa/bellman-ford-algorithm> [Accessed 12 February 2021]. Tutorialspoint.com. (2020). Data Structure and Algorithms - Stack - Tutorialspoint. [online] Available at: https://www.tutorialspoint.com/data_structures_algorithms/stack_algorithm.htm. [3]. GeeksforGeeks. 2021. Abstract Data Types - GeeksforGeeks. [online] Available at:<https://www.geeksforgeeks.org/abstract-data-types/> [Accessed 11 February 2021]. Tutorialspoint.com. 2021. Data Structure and Algorithms - Stack - Tutorialspoint. [online] Available at:<https://www.tutorialspoint.com/data_structures_algorithms/stack_algorithm.htm#:~:text=A%20 stack%20is%20an%20Abstract,used%20in%20most%20programming%20languages.&text=Likew ise%2C%20Stack%20ADT%20allows%20all,%2Din%2Dfirst%2Dout.> [Accessed 11 February 2021] [6]. Techopedia.com. 2021. What is Software Stack? - Definition from Techopedia. [online] Available at:<https://www.techopedia.com/definition/27268/softwarestack#:~:text=A%20software%20stack%20is%20a,that%20work%20as%20a%20set.> [Accessed 11 February 2021]. GeeksforGeeks.2021.Queue Data Structure-GeeksforGeeks. [online]Available at: <https://www.geeksforgeeks.org/queue-data-structure/> [Accessed 11 February 2021].