
















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

















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
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:
Learning Outcomes and Assessment Criteria (Assignment 1) Pass Merit Distinction LO1 Examine abstract data types, concrete data structures and algorithms D1 Analyse the operation, using illustrations, of two network shortest path algorithms, providing an example of each. P1 Create a design specification for data structures explaining the valid operations that can be carried out on the structures. P2 Determine the operations of a memory stack and how it is used to implement function calls in a computer. 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. LO2 Specify abstract data types and algorithms in a formal notation D2 Discuss the view that imperative ADTs are a basis for object orientation and, with justification, state whether you agree. 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.
An ADT is a type of data structure defined by its behavior rather than its implementation in computer science. It is a means of encapsulating both the data and the actions that can be performed on the data.
List, stack, and queue are a few typical ADTs that have proven helpful in a wide range of applications. 2.1. List The list of Abstract Data Types is made up of many elements that are linearly related to one another. A linear connection implies that, with the exception of the first variable, each variable on the list has a distinct successor. Moreover, lists feature a naturally occurring characteristic called size, which is essentially the number of elements in the list. This list can be modified. List is another abstraction in which other classes support the real details of the data form. These classes include LinkedList, which is inside carried out using the data construction of LinkedList, and Array List, which is inside carried out using Arrays. The List ADT Functions is given below:
The last component of the list points to null, and the head pointer is focused on the main node. The head pointer zeroes out at null when the list is empty. Figure 1 : Linked List (Linked List Data Structure - GeeksforGeeks) There are four types of linked lists:
2.2.1. Example Figure 6 : Illustration for push a element onto stack and after push (Data Structure and Algorithms - Stack (tutorialspoint.com)) Figure 7 : Illustration for pop operation the topmost element and stack after pop (Data Structure and Algorithms - Stack (tutorialspoint.com)) 2.2.2. Applications Function Call: Function Call: Information about dynamic functions or subroutines is stored on the stack. String Reversal: Switching a string is nothing new to Stack. Individual characters from the string are pushed into the stack, and then someone is pulled out of the stack.
Dequeue: Removes an element from the queue's beginning and returns it Figure 9 : Dequeue (p5.js | Dequeue Operation in Queue - GeeksforGeeks) 2.3.2. Applications
A data structure called a memory stack is used to store and control how much memory a program is allotted. Due to the fact that it is a Last In First Out (LIFO) data structure, the last item added to the stack is also the first one to be taken away from it. The system creates a section of memory known as a stack when a program is run. This stack is used to store the program's data, function parameters, and return addresses. The system maintains the return address and the function's parameters on the stack each time a function is called, and the size of the stack is fixed and predetermined. Data is removed from the stack and control is returned to the original application after the function completes. Figure 10 : Memory Stack (Stack Memory - an overview | ScienceDirect Topics) 1.1. How the memory is organized Data is arranged in a Last-In-First-Out (LIFO) pattern using a sort of memory management technique called stack. As a result, the item that was most recently placed to the stack is the one that is taken out first. The stack is a tool used in memory management to control memory allocation. The memory management will allot memory for a program to use when it is executing. Each block of this RAM that is allocated is placed in the stack. The memory manager will maintain track of the stack's blocks and always move the following block to the top. The memory management will take the top block off the stack and give it to the program when it requires extra memory. The memory management will release the memory and add it back to the stack after the program is done.
items) (stack). Following the initial plate, which is pushed to the bottom of the stack, all subsequent plates are placed in order. The most inaccessible data item is inserted first and placed at the bottom of the stack. The Pop Operation: Data elements are removed from a loaded stack using the pop operation. In our plate dispenser picture, the most recently inserted plate (data item) is at the top of the stack. This data item is the first to be erased, and it is popped off the stack. Examine the spring-loaded mechanism at the base of the plate dispenser. When a plate is removed, it rises the stack of plates. Things in that order continue to appear in memory. The Peek Operation: During this procedure, no data items are added or removed from the stack. The peek action only requests the data item at the top of the stack (the most recently pushed item). The Search Operation: During this procedure, no data items are added to or removed from the stack. Any data item in the stack whose address the search operation requests. It establishes the item's placement in relation to the item at the top of the stack.
In memory management, a method (function) call is stored in a stack. Each time a method is called, a new entry is added to the stack, indicating the location of the instruction that called the method, the arguments it received, and the address to which it should return. When a method returns, the top of the stack is removed, and the instruction that called the method is then reached using the return address. After the program reaches the main function, the stack is completely popped off and the program terminates, which is repeated numerous times. Figure 12 : A stack that stores activation records. (Function Calls and the Call Stack — Programming and Data Structures 0.2 documentation (eecs280staff.github.io))
Figure 13 : A stack that grows downward rather than upward. (Function Calls and the Call Stack — Programming and Data Structures 0.2 documentation (eecs280staff.github.io)) The main() function is invoked when the program is run, which causes an activation record to be created and added to the top of the stack. The activation record for foo() is thus placed at the top of the stack when main() invokes foo(). The activation record for bar() is then placed on the stack after bar() is called. Bar(activation )'s record is taken off the stack when it returns. When foo() is finished, its activation record is deleted. Lastly, when the method returns, the activation record for main() is deleted.