






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
assignment 1-1649-pass (data structure)
Typology: Assignments
1 / 12
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 Trần Văn Tưởng Student ID GCH Class GCH1107 Assessor name Do Hong Quan 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 Tưởng Grading grid P1 P2 P3 M1 M2 M3 D1 D
Grade: Assessor Signature: Date: Internal Verifier’s Comments: IV Signature:
An object's behavior is determined by a set of values and a set of actions, and they are referred to as the abstract data type (ADT) or class. The ADT specification merely specifies the tasks that must be completed; it makes no statement of how they will be carried out. It is unclear what algorithms will be applied to carry out the operations and how the data will be arranged in memory. Because it provides an implementation- independent view, it is referred to be "abstract." (GeeksforGeeks, 2023). Figure 1 :Abstract data type (GeeksforGeeks, 2023) For example, a list ADT can store a collection of values of the same type, and allow operations such as adding, removing, or accessing an element at a given position. However, the user does not need to know how the list is stored in memory, or what algorithms are used to perform the operations. An ADT is like a black box that only shows its functionality, but not its inner structure. ADT provides several benefits for software development, such as:
Figure 3 :Stack application in Function call The food() function is empty, myFavouriteFood() calls food(), and main() calls myFavouriteFood(). When the program is executed, it starts from main(), which calls myFavouriteFood (), which in turn calls food(). Since food() has no code, it does nothing and returns. Execution then goes back to myFavouriteFood (), which completes execution and returns. Finally, main() finishes executing, and the program ends.
4. Queue ADT A queue is an abstract data type (ADT) that represents a collection of elements in a specific order. It follows the First-In-First-Out (FIFO) principle, meaning that the element added first will be the first one to be removed. Just like people standing in a queue, the first person to join the queue is the first one to proceed. Queue operations: Boolean enQueue(E data ): add a new element to the end of the queue. Parameters: a new element with value is data and data is the element added to the end of the queue. Return: true when when the element is successfully added to the end of the queue. False when the element enters the queue item due to capacity limitations and other reasons. Dequeue (): remove and return the front element from the queue. Return: returns the element removed from the front of the queue. Peek (): allows you to access the front element of the queue without removing it. Return: returns the element at the front of the queue without modifying the queue.
b. Describe what are pre-condition, post-condition, error-condition. A pre-condition is a condition that must be true before a method or function is called. It specifies what must be in place before the method is executed. (Matthew, 2012) A post-condition is a condition that must be true after a method or function has finished executing. It specifies what the method will have accomplished when it finishes. (Matthew, 2012) An error-condition is not as commonly used as pre and post-conditions, but it can refer to conditions that are checked for errors at the beginning of a method. (Matthew, 2012) c. Specify Stack’s operations using this formal specification language. Stack stack; Vt.size() - > n(n>=0); Max: the total number of elements can be stored. Push(E data): Boolean flag Pre-condition:
Peek(): Pre-condition: stack.size() > 0 Post-condition: data Error-condition: stack.size() = 0 isEmpty(): boolean flag Pre-condition: none Post-condition: