Abstract Datatype
Abstract Datatype
Topperworld.in
The user of data-types does not need to know how that data type is
implemented, for example, we have been using Primitive values like int,
float, char data types only with the knowledge that these data type can
operate and be performed on without any idea of how they are
implemented.
So a user only needs to know what a data type can do, but not how it will
be implemented. Think of ADT as a black box which hides the inner
structure and design of the data type. Now we’ll define three ADTs
namely List ADT, Stack ADT, Queue ADT.
©Topperworld
Data Structure and Algorithm
1. List ADT
View of list
©Topperworld
Data Structure and Algorithm
2. Stack ADT
View of stack
©Topperworld
Data Structure and Algorithm
3. Queue ADT
View of Queue
• 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.
• 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.
©Topperworld
Data Structure and Algorithm
➔Features of ADT:
Abstract data types (ADTs) are a way of encapsulating data and operations
on that data into a single unit. Some of the key features of ADTs include:
Overall, ADTs provide a powerful tool for organizing and manipulating data
in a structured and efficient manner.
©Topperworld
Data Structure and Algorithm
➔Advantages:
➔Disadvantages:
©Topperworld