Java Abstract Data Type in Data Structure – ADT
Keeping you updated with latest technology trends, Join DataFlair on Telegram
1. Java ADT – Objective
Previously we saw, Data Structure in Java, and today we will talk about our fourth part Java Abstract Data Type in Data Structure notes, with a list of Abstract Data Types: List ADT, Stack ADT, and Queue ADT in detail, also we will discuss abstract data types problems.
So, let us start Java Abstract Data Types.
2. What is the Java Abstract Data Type (ADT)?
Java abstract data type(ADT) in a data structure is a type of data type whose behaviour is defined by a set of operations and values.
In Java abstract data type, we can only know what operations are to be performed and not how to perform them i.e. it does not tell how algorithms are to be implemented or how the data will be organized in the memory. This type is thus called abstract as it does not give the view of implementation.
3. List of Abstract Data Types (ADTs)
a. List ADT
A list abstract data type is the type of list which contains similar elements in sequential order and following are the operations which can be performed on list.
i. get() – Return an element from the list.
ii. insert() – Insert an element at any position.
iii. remove() – Remove the first occurrence of any element from a non-empty list.
iv. removeAt() – Remove the element at a predefined area from a non-empty list.
v. Replace() – Replace an element by another element.
vi. size() – Returns number of elements of the list.
vii. isEmpty() – Return true if the list is empty, else return false.
viii. isFull() – Return true only if the list is full, else return false.
b. Stack ADT
A stack contains similar elements which are in an ordered sequence. All the operations in stack takes place at the top of the stack. Following are the operations which are performed on the stack-
i. push() – Insert an element at the top of stack.
ii. pop() – Remove an element from the top of the stack, If it is not empty.
iii. peep() – Returns the top element of stack without removing it.
iv. size() – Returns the size of the stack.
v. isEmpty() – Return true if the stack is empty, else it returns false.
vi. isFull() – Return true if the stack is full, else it returns false.
c. Queue ADT
The elements of the queue are of the same type which are arranged sequentially. The operations can be performed at both ends, insertion is done at rear end deletion is done at the front end. Operations performed on the queue are as follows-
i. enqueue() – Inserting an element at the end of queue.
ii. dequeue() – Removing an element of the queue.
iii. peek() – Returns the element of the queue without removing it.
iv. size() – Returns the number of elements in the queue.
v. isEmpty() – Return true if the queue is empty, else it returns false.
vi. isFull() – Return true if the queue is full, else it returns false.
So, this was all about Java Abstract Data Types. Hope you like our explanation.
Hence, In this Java ADT tutorial, we are learned Java Abstract Data Type (ADT) and the types of Abstract Data Type in Java: List ADT, Stack ADT, and Queue ADT in detail with the end of this tutorial we have covered all types of data structures. In the upcoming tutorials, we will study in detail the different types that we have studied. Furthermore, if you have any query, feel free to ask in a comment section.
See Also – Identifiers in Java