








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
This assignment explores the fundamental concepts of abstract data types (adts) with a focus on stack and queue implementations. It provides a comprehensive overview of their operations, including push, pop, enqueue, and dequeue, along with real-world applications. The document also includes a practical component involving the development of a student management system, demonstrating the application of these data structures in a real-world scenario.
Typology: Thesis
1 / 14
This page cannot be seen from the preview
Don't miss anything!
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 Nguyễn Minh Ánh Student ID BH Class SE06203 Assessor name Tạ Quang Hiếu 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 Anh Grading grid P1 P2 P3 M1 M2 M3 D1 D
Grade: Assessor Signature: Date: Internal Verifier’s Comments: IV Signature:
As an in-house software developer for Soft Development ABK, I have been entrusted with a dual responsibility in my role as lead software project manager. This assignment aims to address two critical
applied to carry out the operations and how the data will be arranged in memory. Because it provides an implementationindependent view, it is referred to be "abstract." Users of data types don't always need to understand how those kinds are implemented. For instance, we've been utilizing primitive values like int, float, and char data types merely knowing that they may be used and operated upon without needing to know how they're implemented. 1.2. Stack ADT a. What is stack? An Abstract Data Type (ADT), or stack, is a widely used data type in most computer languages. Because it functions similarly to actual stacks, such a deck of cards or a pile of plates, etc., it was given the name "stack. The last element added would be the first element removed in a stack that adheres to the LIFO (Last in - First out) structure. b. Operations on stacks? push(int data) to insert an element to the top of the stack pop() to remove an element from the stack. top() Returns the top element of the stack. isEmpty() returns true if stack is empty else false. size() returns the size of stack.
Push(int data) function Push(int data): Boolean Purpose Add a new element to the top of the stack Parameters A new element with value is data Return The function will return true if the add is successful and fail if the add is not successful The push method checks whether the stack is empty or not. If it is empty then it places the new element as the top. If not empty, it creates a new node and assigns the element to be added to that node, then assigns the new node to the top of the stack and updates the top of the stack to point to the new node. Explanation: First, check if the list is empty or not. Given that there are two entries, we must append the parameter value of 91 to the beginning of the list. Consequently, the list's beginning now has the new value of 91. Pop() Pop(): Integer Purpose Delete the element at the top of the stack Parameters No parameter Return If the list is null return null, if the list is not null method will return the deleted value Check if the stack is empty or not. If empty, return null. If not empty, then access the element at the top of the stack and store it in a temporary variable. Then, remove that element from the stack, and update the top of the stack to point to the next element. Returns a temporary variable containing the deleted element.
isEmpty(): boolean Purpose Check if the stack is empty or not Parameters No parameter Return Return true if the stack is null; return false otherwise. Compares the top of the stack with a special value, usually -1, to see if the stack is empty or not. If the top of the stack is equal to the special value, then the stack is empty and returns true. If not, then the stack is not empty and false is returned. Explanation: Image on the left, there are no elements in the list so it will return true. The remaining image, because it has 3 elements, will return true size size(): int Purpose Get the total number of elements in the list. Parameters No^ parameter Return If the list has no elements, return 0. If there are, return the value of the counter variable count. First initialize a counter variable and assign it to 0. Initialize a pointer and assign it to the top of the stack. Repeat until the pointer is null: Increase the counter variable by 1. Update the pointer to the next element in the stack. Returns the counter variable.
Explanation: The image on the left, because the list has 2 elements, will return the value 3. The remaining image, because it has no elements, will return 0. c. Application of Stack Data Structure Function calls and recursion : When a function is called, the program's current state is pushed into the stack. The state is removed from the stack to allow the prior function to continue running after the function returns. Undo/Redo operations : Stacks are used by many programs' undo-redo features to maintain track of prior actions. Every action that is taken is added to the stack. The action can be undone by popping the top element of the stack and carrying out the opposite action. Expression evaluation : Expressions in infix, postfix, and prefix notations are evaluated using the stack data structure. Pushing operators and operands into the stack allows actions to be carried out based on the elements at the top of the stack. Browser history : To record the webpages you visit, web browsers employ stacks. The URL is added to the stack each time you visit a new page, and when you use the back button, the previous URL is removed from the stack.
Balanced Parentheses: To determine whether or not parentheses are balanced, utilize the stack data structure. A closing parenthesis is removed from the stack after an opening parenthesis has been pushed onto it. The parentheses are balanced if the stack is empty at the conclusion of the expression. d. Application of Stack in real life
of the queue. If the queue is empty, the object being pushed is both front and back. Explanation : Currently on the list there are 2 people queuing to buy food and at this time more people will be sorted and displayed according to each member's code. With enQueue(11) as argument representing the value to add to the end of the row. Then return true if adding successfully and otherwise return false Dequeue deQueue(): Integer Purpose Remove an element from the front of the queue Parameters No parameter Return The function will return the deleted value after deletion. The deQueue function removes the item at the head of the queue and, should the deletion be successful, returns the item. If delete fails for any reason—for example, an empty queue—Null is returned. The item that is in front will be the one that is deleted.
Explanation: The getFront() function returns the top id number of the food buyer. If the list is empty, it returns null. In the illustration you can see that when calling the function, it returns 98. c. Application of Queue Data Structure
3.3. Quick Sort