# Which of the Following Is an Abstract Data Type Answer?

//

Angela Bailey

An abstract data type (ADT) is a high-level description of a collection of data and the operations that can be performed on that data. It is a concept in computer science that allows us to define our own data types based on existing primitive data types.

Examples of Abstract Data Types:

• Stack
• Queue
• List
• Tree
• Graph

## Definition:

A stack is an ADT that follows the Last-In-First-Out (LIFO) principle. It is similar to a stack of plates where the last plate placed on top is the first one to be removed.

## Operations:

A stack typically supports the following operations:

• Push: Adds an element to the top of the stack.
• Pop: Removes and returns the topmost element from the stack.
• Peek: Returns the topmost element without removing it.
• isEmpty: Checks if the stack is empty or not.

## Definition:

A queue is an ADT that follows the First-In-First-Out (FIFO) principle. It resembles a line of people waiting for their turn, where the person who arrives first gets served first.

## Operations:

A queue typically supports the following operations:

• Enqueue: Adds an element to the back of the queue.
• Dequeue: Removes and returns the element from the front of the queue.
• Front: Returns the element at the front of the queue without removing it.
• isEmpty: Checks if the queue is empty or not.

## Definition:

A list is an ADT that represents an ordered collection of elements. It allows duplicates and maintains the insertion order.

## Operations:

A list typically supports the following operations:

• Add: Adds an element to the list at a specified position.
• Delete: Removes an element from the list at a specified position.
• Get: Returns an element from the list at a specified position.
• Size: Returns the number of elements in the list.

## Definition:

A tree is an ADT that represents a hierarchical structure. It consists of nodes connected by edges, where each node can have zero or more child nodes.

## Operations:

A tree typically supports various operations, including but not limited to:

• AddNode: Adds a new node to the tree.
• DeleteNode: Deletes a node from the tree.
• Traverse: Visits each node in a specific order (e.g., pre-order, in-order, post-order).

## Definition:

A graph is an ADT that represents a collection of interconnected nodes or vertices. It is used to model relationships between objects.

## Operations:

A graph typically supports various operations, including but not limited to:

• AddVertex: Adds a new vertex to the graph.
• DeleteVertex: Deletes a vertex from the graph.
• AddEdge: Adds an edge between two vertices in the graph.
• DeleteEdge: Deletes an edge between two vertices in the graph.

In conclusion, abstract data types provide a way to define and work with custom data structures that suit specific needs. They encapsulate the underlying implementation details, allowing us to focus on the logical operations performed on the data. Being familiar with these ADTs helps in designing efficient algorithms and solving complex problems in computer science and software development.