









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
A BTEC Level 5 HND Diploma in Computing assignment focusing on Unit 19: Data Structures and Algorithms. The student, Nguyen Le Hoang Anh, has submitted their work for assessment, which includes the design and implementation of stack and queue Abstract Data Types (ADTs) and the removal of duplicate values from these data structures. an in-depth explanation of the operations of stack and queue, including push, peek, pop, size, enqueue, and dequeue. Additionally, the document discusses the concept of asymptotic analysis and its use in assessing the effectiveness of algorithms.
Typology: Essays (high school)
1 / 16
This page cannot be seen from the preview
Don't miss anything!










Resubmission Feedback: Grade: Assessor Signature: (^) Date: Internal Verifier’s Comments:
I. Design and implementation of stack ADT and Queue ADT (P4)
Figure 1. Push operation First I declared new node then check if it null then will print to screen message, if not null will insert x to data of node then link node to top then assign top to node, finally I will plus 1 to nodesCount. Peek(): Figure 2. Peek operation I will check if stack is empty, if true then print to screen message, if not then print data of top node.
Queue operation: Enqueue: First I created new node then check if this front of node is empty is not which mean queue already have node or not, if not then assign this.front = node and increase size by 1 and rear is also node, if front is not null then the node next to rear will be node then increase size by 1, rear now is node. Figure 5. Enqueue operation
Dequeue: first thing to do is check if queue is empty or not, if it empty then return - 1, if not empty then declare data equal to this.peek() and peek() operation return data of front node of queue, next create Node temp equal to front then check if queue has only one node then assign rear and front to null, else this.front will be moved to next node and prev will be null. After all decrease size to 1 and return data. Figure 6. Dequeue operation II. Application
III. Implement error handling and report test results
type Push() Normal LinkedList:[1,3,4]; LinkedList:[5,3,2 Same as Pass Push(5); ,1]; expected Size: 4 Peek() return 5 1 Stack ADT Pop() Normal LinkedList:[1,3,4]; LinkedList:[3,2 ,1]; Same as Pass Pop() Removed: 5 expected Size: 3 Peek() return 3 Pop() Data LinkedList[] Print “stack is Same as Pass validation Pop() empty” expected Peek() Normal LinkedList:[1,3,4]; Return 3 Same as Pass Peek() expected Peek() Data LinkedList[] Print “stack is Same as Pass validation empty” expected Enqueue( Normal DoubleLinkedlist[1,2, DoubleLinkedlist[1 Same as Pass ) 3]; ,2,3,10]; expected Enqueue(10) Size: 4 Peek() return 1 2 Queue Dequeue Normal DoubleLinkedlist[1,2, DoubleLinkedlist[1 Same as Pass ADT 3,10]; ,2,3]; expected Dequeue() Size: 3 Removed 10 Peek() return 1 isEmpty() Data DoubleLinkedlist[] Print message “list Same as Pass validation isEmpty() is empty” expected isEmpty() Data DoubleLinkedlist[1,2, Print message “list Same as Pass validation 3] is not empty” expected isEmpty() 3 Remove RemoveD Normal Linkedlist[1,2,2,3] Linkedlist[1,2,3] Same as Pass Duplicate up() expected
IV. Discuss how asymptotic analysis can be used to assess the effectiveness of an algorithm Asymptotic analysis refers to the computing of the running time of any piece of code or the operation in a mathematical unit of a computation. Its operation is computed in terms of a function like f(n). (Khatri, 2018)
(Studios guy,2022)
Time complexity Time complexity estimates how an algorithm performs regardless of the kind of machine it runs on. You can get the time complexity by “counting” the number of operations performed by your code. This time complexity is defined as a function of the input size n using Big-O notation. n indicates the input size, while O is the worst- case scenario growth rate function. Example: In this example, the time complexity is O(1) because the process will run only one time and the space complexity will be 3 variables are x, y and sum. In this example, the loop will loop n time base on array length so time complexity here is O(n), auxiliary space are 2 variables sum and I and space for input data is size of array, in this example is 5.
References Anon., 2021. geeksforgeeks.org. [Online] Available at: https://www.geeksforgeeks.org/g-fact-86/ [Accessed 26 6 2022]. Jalli, A., n.d. codingem. [Online] Available at: https://www.codingem.com/what-is-a-fifo-queue/ [Accessed 23 6 2022]. Vineet Choudhary. [Online] Available at: https://developerinsider.co/big-o-notation-explained-with- examples/ [Accessed 2022]. GeeksforGeeks. “Analysis of Algorithms | Set 1 (Asymptotic Analysis)”. [Online]. Available at: https://www.geeksforgeeks.org/analysis-of-algorithms-set- 1 - asymptoticanalysis/#:~:text=Asymptotic%20Analysis%20is%20the%20big,increases%20with%20the%20input%20si ze. [Accessed 2022, June 02] Kalkicode “Implement queue using doubly linked list in java”. [online]. Available at: https://kalkicode.com/implement-queue-using-doubly-linked-list-in-java [Accessed 2021, November 06]