Abstract Data Types: A Comprehensive Guide with Examples and Applications, Lecture notes of Data Mining

Implement a complex ADT and algorithm in an executable programming language to solve a well defined problem.

Typology: Lecture notes

2020/2021

Uploaded on 11/06/2021

hai-nguyen-14
hai-nguyen-14 🇻🇳

4.4

(7)

5 documents

1 / 19

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ASSIGNMENT 1 FRONT SHEET
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
GCD191185
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
D2
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13

Partial preview of the text

Download Abstract Data Types: A Comprehensive Guide with Examples and Applications and more Lecture notes Data Mining in PDF only on Docsity!

ASSIGNMENT 1 FRONT SHEET

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

 Summative Feedback:  Resubmission Feedback:

Grade: Assessor Signature: Date: Internal Verifier’s Comments: IV Signature:

  • I. INTRODUCTION.
  • II. Abstract data type (P1). (Abstract Data Types, 2021)
      1. Definition.
      • a. List ADT
      • b. Stack ADT
      • c. Queue ADT
      1. Example of a general ADT. (Data Structure and Algorithms - Linked List, 2021)
      • a. Types of Linked List
      • b. Basic Operations
      • c. Code and output of Linked List ADT
      1. ADT usages
    • a. Application of Stack in memory.
      • b. Application in an ADT (P3) (Applications of Stack, n.d.)
  • References
  • Figure 1 Node.java TABLE OF FIGURE
  • Figure 2 LinkedList.java
  • Figure 3 SInglyLinkedList.java
  • Figure 4 addLast() and addFirst()
  • Figure 5 getFirst() and getLast()
  • Figure 6 removeFirst() anf removeLast()
  • Figure 7 main()
  • Figure 8 isEmpty()
  • Figure 9 size()
  • Figure 10 Result of linked list.................................................................................................................................
  • Figure 11 A stack layout during the function call....................................................................................................
  • Figure 12 Stack Representation
  • Figure 13 Stack.java
  • Figure 14 main()
  • Figure 15 Stack()
  • Figure 16 push()
  • Figure 17 pop()......................................................................................................................................................
  • Figure 18 peek()
  • Figure 19 isEmpty()
  • Figure 20 Result of Stack
  • Table 1 Linked List ADT's operations. TABLE OF TABLE
  • Table 2 Stack ADT' operation

I. INTRODUCTION.

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:

  1. Inform my team about the design and implementation of abstract data types.
  2. Create a presentation to all collaborating partners on how to use ADT to improve software design, development, and testing.
  3. Write an introductory report to distribute to all partners on how to specify abstract data types and algorithms in a formal notation. P1 Create a design specification for data structures explaining the valid operations that can be carried out on the structures. II. Abstract data type (P1). (Abstract Data Types, 2021) 1. Definition. Abstract Data type (ADT) is a type (or class) for objects whose behavior is defined by a set of value and a set of operations.

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

  • When a function returns, the top stack frame is removed  Old frame pointer and return address are restored  Stack pointer is adjusted  The caller can find the return value, if there is one, on top of the stack
  • Because of recursion, there may be multiple frames for the same function on the stack. Stack frame constructed during the function call for memory allocation implicitly. Explicitly, memory allocation can be requested from and released to heap area using malloc(),calloc(),realloc(),new, free() and delete respectively. A typical layout of a stack frame is shown below although it may be organized differently in different operating systems:  Function parameters.  Function’s return address.  Frame pointer.

 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