Abstract Data Types

ABSTRACT DATA TYPES

INTRODUCTION

In this article, we’ll learn about ABSTRACT DATA TYPES in data structures, I.e what is ADT what ADT consists of, examples of ADT, how ADT is performed, and the advantages of ADT.

DATA TYPE:

The data type is used to declare the variables which tell the compiler or interpreter the type of data that variable consists of.

There are two data types are there

  1. Built-in data types
  2. Abstract data type(user-defined data types)
  3. In simple terms, abstract data types are made with the help of built-in data types.

Examples of built-in data types and abstract data types.

Built-in             abstract data types

Int                         list ADT

Char                     stacks ADT

float                     queues ADT

Definition of (ADT):

ADT is known as a theoretical constructor which consists of the data as well as the operations to be performed on the data to implementation.

In simple terms, it is data structure along with their operations these following are not in-built these are known as abstract data types.

  • The abstract data type is also known as a user-defined data or mathematical data structure.
  • Abstract data type concerns only with what the data represented and not how it will be constructed.
  • Abstract data type specifies what is to be done but how it’s done is not specified all the implementation details are hidden.

Abstract data type consists of the following:

See also  Time and Space Complexities from code

1 . Data

2 . Operations

3 . Implementations

4 . Errors rectifier

  • DATA: It describes the structure of the data used in abstract data type.
  • Operation: It describes the valid operations for the abstract data type.
  • Implementation: It describes how the hidden operations are performed.
  • ERROR: It describes how to deal with errors.

HOW AN ABSTRACT DATA TYPE MADE

  • We form abstract data types with the help of built-in data types.
  • By using built-in data type, we declare the type of the variables.
  • Operations is been performed between the variables(push, pop,…).
  • By using operations we perform the implementation.
  • We solve the errors.

A user knowing what a data type do is good enough, it’s not mandatory to know about all the implementation.

Now we’ll see about the List of Abstract data types

List ADT:

Let’s see the List ADT functions now:

get(): the get function is used to return the value from the following data structure from the desired position.

insert(): Insert function is used to place an element at the desired position.

remove(): it is a function that removes the first occurrence of the element.

removeAt(): Remove is a function used to remove the element from the desired position.

replace(): replace is a function that replaces the element at any position with another element.

size(): size is a function that returns the number of elements in the list.

isEmpty(): it is a function that returns either true if the list is empty or false if the list had some elements.

isFull(): it is a function if(list is full) return true else return false

Stack ADT:

Let’s see the Stack ADT functions now:

See also  Best 3 ideas for Project development using Java for beginners in 2024

push(): push is a function that is used to insert an element at the end of the stack which I know as the top.

pop(): pop is a function that removes and returns the element from the top of the stack.

peek(): peek is a function that only returns the at top of the stack.

size(): size is a function that returns the size of the stack.

isEmpty(): it is a function that returns either true if the stack is empty or false if the list had some elements.

isFull(): it is a function if(stack is full) return true else return false.

Queue ADT:

Let’s see the Queue ADT functions now:

enqueue(): enqueue is the function that inserts an element from last to first I.e the end of the queue.

dequeue(): dequeue is a function that removes and returns the first element from the queue.

peek(): peek is a function that returns the element of the queue without removing it.

size(): size is a function that returns the number of elements present in the queue.

isEmpty(): it is a function that returns either true if the queue is empty or false if the list had some elements.

isFull(): it is a function if(the queue is full) return true else return false.

Advantages of abstract data type:

  • The abstract data type is reusable and ensures robust DS.
  • It reduces coding efforts.
  • Encapsulation ensures that data can’t be copied
  • The abstract data type is based on principles of object-oriented programming and software engineering.

Conclusion

That’s it from this tutorial. Hope you guys found it interesting. We have learned about the datatype, abstract data type, examples of built-in datatype and user-defined datatype, operations performed by the abstract data types, and the advantages of the abstract data types. Happy coding!

See also  Difference between Coder, Programmer, and Developer.

Leave a Comment

Your email address will not be published. Required fields are marked *

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

we provide projects, courses, and other stuff for free. in order for running we use Google ads to make revenue. please disable adblocker to support us.

Powered By
100% Free SEO Tools - Tool Kits PRO