











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
Implement a complex ADT and algorithm in an executable programming language to solve a well defined problem.
Typology: Lecture notes
1 / 19
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 24/10/2021 Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name VU THI HUONG^ Student ID GCD Class GCD0807B Assessor name Truong Nguyen Xuan Vinh 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 Vu^ Huong Grading grid P1 P2 P3 M1 M2 M3 D1 D
Grade: Assessor Signature: Date: Internal Verifier’s Comments: IV Signature:
In the scenario, I work as an in-house software developer for Softnet Development Ltd, a software store that provides networking solutions that is part of a service development partnership project. service and company won a contract to design and develop a middleware solution that will interface at the front-end with multiple desktop provisioning interfaces including SOAP, HTTP, JML and CLI, and back-end - Networking telecommunications providers via CLI. My account manager has given me the following tasks:
The head node and the data nodes are encapsulated in the ADT. The calling function can only see the pointer to the stack. The stack head structure also contains a pointer to top and count of number of entries currently in stack. A Stack contains elements of the same type arranged in sequential order. All operations take place at a single end that is top of the stack and following operations can be performed: push() – Insert an element at one end of the stack called top. pop() – Remove and return the element at the top of the stack, if it is not empty. peek() – Return the element at the top of the stack without removing it, if the stack is not empty. size() – Return the number of elements in the stack. isEmpty() – Return true if the stack is empty, otherwise return false. isFull() – Return true if the stack is full, otherwise return false. c. Queue ADT The queue abstract data type (ADT) follows the basic design of the stack abstract data type. Each node contains a void pointer to the data and the link pointer to the next element in the queue. The program’s responsibility is to allocate memory for storing the data. A Queue contains elements of the same type arranged in sequential order. Operations take place at both ends, insertion is done at the end and deletion is done at the front. Following operations can be performed: enqueue() – Insert an element at the end of the queue. dequeue() – Remove and return the first element of the queue, if the queue is not empty. peek() – Return the element of the queue without removing it, if the queue is not empty. size() – Return the number of elements in the queue. isEmpty() – Return true if the queue is empty, otherwise return false. isFull() – Return true if the queue is full, otherwise return false.
2. Example of a general ADT. (Data Structure and Algorithms - Linked List, 2021) A linked list is a sequence of data structures, which are connected together via links. Linked List is a sequence of links which contains items. Each link contains a connection to another link. Linked list is the second most-used data structure after array. Linked list can be visualized as a chain of nodes, where every node points to the next node.
Linked List contains a link element called first. Each link carries a data field(s) and a link field called next. Each link is linked with its next link using its next link. Last link carries a link as null to mark the end of the list. a. Types of Linked List Singly Linked List: Item navigation is forward only. Doubly Linked List: Items can be navigated forward and backward. Circular Linked List: Last item contains link of the first element as next and the first element has a link to the last element as previous. b. Basic Operations Insertion − Adds an element at the beginning of the list. Deletion − Deletes an element at the beginning of the list. Display − Displays the complete list. Search − Searches an element using the given key. Delete − Deletes an element using the given key. c. Code and output of Linked List ADT Node.java Figure 1 Node.java
getFirst() and GetLast() Figure 5 getFirst() and getLast() removeFirst() and removeLast() Figure 6 removeFirst() anf removeLast()
main() Figure 7 main() isEmpty() Figure 8 isEmpty() isEmpty() is used for checking if the linked list is empty or not. If the list is empty, the display returns true, otherwise returns false size() Figure 9 size() size() is used in the linked list to count the elements in the list. Result
How to organize Stack memory? (Stack Organization, 2021) Stack is a storage structure that stores information in such a way that the last item stored is the first item retrieved. The stack in digital computers is a group of memory locations with a register that holds the address of top of element. This register that holds the address of top of element of the stack is called Stack Pointer. The two operations of a stack are: Push: Inserts an item on top of stack. Pop: Deletes an item from top of stack. In digital computers, stack can be implemented in two ways: Register Stack: A stack can be organized as a collection of finite number of registers that are used to store temporary information during the execution of a program. The stack pointer (SP) is a register that holds the address of top of element of the stack. Memory Stack: A stack can be implemented in a random access memory (RAM) attached to a CPU. The implementation of a stack in the CPU is done by assigning a portion of memory to a stack operation and using a processor register as a stack pointer. The starting memory location of the stack is specified by the processor register as stack pointer. How to make method (function) calls with the Stack? (memory management of the Stack, 2021)
- When a function is called, a new stack frame is created Arguments are stored on the stack Current frame pointer and return address are recorded Memory for local variables is allocated Stack pointer is adjusted
Exception Handler frame. Locally declared variables. Buffer. Callee save registers. Figure 11 A stack layout during the function call. P3 Using an imperative definition, specify the abstract data type for a software stack. b. Application in an ADT (P3) (Applications of Stack, n.d.) The stack is used to evaluate prefix, suffix, and infix expressions. Problems using ADT - specifically the Stack: Expression Transformation: An expression can be represented by prefix, suffix, or infix notation. Stacks can be used to convert one form of expression to another. Parsing: Many compilers use a stack to parse expressions, program blocks, etc., before translating into low-level code. Backtracking: Track previous selections Parenthesis test: The stack is used to test the proper opening and closing of parentheses.
Figure 13 Stack.java b. Main() Figure 14 main() c. Stack() Figure 15 Stack() d. Push()
Figure 16 push() e. Pop() Figure 17 pop() f. Peek() Figure 18 peek() g. isEmpty()
References Abstract Data Types. (2021, 10). Retrieved from https://www.geeksforgeeks.org/abstract-data-types/ Applications of Stack. (n.d.). Retrieved from https://www.thecrazyprogrammer.com/2016/04/applications-of- stack.html Data Structure and Algorithms - Linked List. (2021, 10). Retrieved from https://www.tutorialspoint.com/data_structures_algorithms/linked_list_algorithms.htm memory management of the Stack. (2021, 10). Retrieved from http://www.cs.ru.nl/~erikpoll/sws1/slides/hic3_stack.pdf Stack Organization. (2021, 10). Retrieved from http://www.eazynotes.com/pages/computer-system- architecture/stack-organization.html