Abstract Data Types

Abstract Data Types

Computer scientists utilize abstractions to handle the complexity of issues and the problem-solving process, allowing them to focus on the “big picture” without becoming bogged down in the technicalities. Abstraction is a technique for hiding the specifics of a function so that the user or client can see it at a high level. Now, we’ll look into data abstraction, which is a related concept. An abstract data type (ADT) is a logical definition of how we see data and the operations that are permissible, regardless of how they will be implemented. This means that we are just concerned with what the data represents, not with how it will be produced in the end. The diagram below depicts what an abstract data type is, and how it works. The user interacts with the interface by performing the operations that the abstract data type has defined. The shell with which the user interacts is the abstract data type. One step down, the implementation is covered. The user is unconcerned with the implementation specifics.

Operation of ADT

Operation of ADT

Abstract data types are similar to user-defined data types on which we may run functions without knowing what is included within the datatype or how operations are carried out on it. It is a logical definition or specification of data components and actions that are permissible that is independent of implementation. ADTs are a computer science theoretical notion that is used in the design and study of algorithms, data structures, and software systems, and do not correlate to specific characteristics of computer languages. Even if the coding language remains constant, there may be millions of methods to implement a particular ADT. Any such implementation must adhere to the ADT’s content and behavioral descriptions.

ADT Operation

ADT simply specifies which operation is to be carried out, and it does not specify the ways to carry out these operations. It is not specified in ADT how data will be arranged in memory or what algorithms will be utilized for operations. It’s termed abstract because it provides a perspective that is independent of implementation. As a result, just the fundamentals are known as abstractions, while the details of the process are hidden.

Diagrammatic Explanation

Abstract-data-types

A data structure is a method of implementing Abstract data types. An object is an instance of a class that is produced and stored during the execution of a computer program. A method or member function implements each operation associated with the ADT. Additionally, data members/functions are variables that specify the amount of space required by a data item.

Types of ADT

Types of ADT

Here we will study three types of Abstract Data Types:

Stack ADT

Stack ADT

 

The stack abstract data type is constructed as an ordered collection of things, with items being added to and deleted from the “top” end. Stacks are arranged in a LIFO fashion. The operations on the stack are listed below:

  • isFull(): This is used to determine whether or not the stack is full.
  • isEmpty(): This is used to determine whether or not the stack is empty.
  • push(x): This is used to place x at the top of the stack.
  • pop(): This is used to remove one element from the stack’s top.
  • peek(): This is used to obtain the stack’s topmost member.
  • size(): This function is used to determine the number of elements in the stack.

List ADT

List ADT

We all have a basic idea of what a “list” means. We wish to translate this knowledge into a real data structure with operations that can be implemented. The idea of position is the most significant in the context of lists. To put it another way, we consider the list to have a first element, a second element, and so on. As a result, define a list as a finite, ordered series of data elements. This is similar to the idea of a series in mathematics. In this definition, “ordered” indicates that each element has a place in the list. In this case, the term “ordered” does not imply that the list members are sorted by value. The data is usually kept in a list with a head structure that includes a count, pointers, and the location of the comparison function that is used to compare the data in the list. The data node carries a data structure pointer as well as a self-referential pointer to the next node in the list. On the list, you may do the following operations:

  • get(): Return an element from the list at a certain point in the list.
  • insert(): Add a new element to the list at any point.
  • remove(): In a non-empty list, remove the first occurrence of any element.
  • removeAt(): Remove the entry from a non-empty list at a given position.
  • replace(): A different element can be used to replace an element in any location.
  • size(): The number of elements in the list is returned.
  • isEmpty(): If the list is empty, return true; otherwise, return false.
  • isFull(): If the list is empty, return true; otherwise, return false.

Queue ADT

Queue ADT

 

A queue is a linear data structure with insertion and deletion operations conducted at opposite ends. Adding and deleting items are done at two distinct locations in a queue data structure. The insertion is done on one end, while the deletion is done on the other. In a queue data structure, the insertion action is done at the’rear’ position, whereas the deletion operation is executed at the ‘front’ position. The FIFO (First In First Out) concept is used to conduct insertion and deletion operations in queue data structures. The functions “enQueue()” and “deQueue()” are used to conduct the insertion and deletion operations, respectively. The operations on a queue data structure are as follows:

  • enQueue(value): To add a new element to the queue.
  • deQueue(): To remove an item from a queue.
  • display(): To view the queue’s components

Add Comment