NOIDATUT FREE E LEARNING PLATFORM • AKTU B.TECH

Abstract Data Types (ADT)

An Abstract Data Type (ADT) defines what operations a data structure supports and their expected behaviour without specifying how they are implemented internally in memory or code.


Theory & Explanation

Abstract Data Types (ADT)

In computer science and data structures, an Abstract Data Type (ADT) is a logical model of a data type that specifies what data is stored, what operations can be performed on it, and how those operations behave, while hiding the internal implementation details.

The word abstract means we focus on the interface and rules of use rather than low-level representation such as array indices, pointer links, or specific programming language syntax. A single ADT can be implemented in more than one way depending on performance and memory needs.

ADT vs. Data Structure

Students often confuse an ADT with a data structure. In simple terms, an ADT is the specification (the "what"), whereas a data structure is the concrete implementation (the "how").

Basis Abstract Data Type (ADT) Data Structure
Meaning Logical description of data and allowed operations. Physical arrangement of data in memory to realize an ADT.
Focus What operations do and their rules/behaviour. How operations work internally and their time/space cost.
Examples List ADT, Stack ADT, Queue ADT, Map/Dictionary ADT. Array, Singly/Doubly Linked List, Dynamic Array, Hash Table.

Why Are ADTs Important?

  • Modularity and Encapsulation: Users interact only through well-defined operations, so internal changes do not break code that uses the ADT.
  • Flexibility of Implementation: You can switch from an array-based implementation to a linked-list implementation if resizing or insertion patterns change.
  • Clear Problem Modelling: ADTs match real-world rules—such as first-come, first-served queues or undo histories—making algorithm design cleaner and easier to read.

Common Examples of ADTs

1. Stack ADT (LIFO — Last In, First Out)

A Stack ADT stores elements in an ordered sequence where insertions and removals happen only at one end, called the top. It follows the Last In, First Out (LIFO) principle, similar to a pile of plates or the browser back/undo history.

  • push(x): Inserts element x onto the top of the stack.
  • pop(): Removes and returns the top element of the stack (fails/underflows if empty).
  • peek() or top(): Returns the top element without removing it.
  • isEmpty(): Checks whether the stack has no elements.

Example & Implementation Note: Suppose we push 10, then 20, then 30 onto a stack. Calling pop() returns 30 first. This Stack ADT can be implemented using either a fixed/dynamic array (tracking a top index) or a linked list (inserting and deleting at the head).

2. Queue ADT (FIFO — First In, First Out)

A Queue ADT represents a collection where new elements are added at one end (rear or back) and removed from the other end (front). It follows the First In, First Out (FIFO) rule, just like people standing in a ticket or billing line.

  • enqueue(x): Adds element x at the rear of the queue.
  • dequeue(): Removes and returns the element at the front of the queue.
  • front() or peek(): Views the front element without removing it.
  • isEmpty(): Checks whether the queue is empty.

Example & Implementation Note: If print jobs Doc1, Doc2, and Doc3 are enqueued in order, Doc1 is dequeued and printed first. Internally, a Queue ADT can be built using a circular array or a linked list with front and rear pointers.

3. List ADT

A List ADT stores a linear sequence of elements a0, a1, ..., an-1 where position matters and duplicate values are generally allowed.

  • insert(pos, x): Inserts element x at a given position or at the end.
  • delete(pos) or remove(x): Deletes an element by position or value.
  • get(pos): Retrieves the element at position pos.
  • size() / isEmpty(): Returns the number of elements or checks emptiness.

Example & Implementation Note: A student roll-number list or playlist can be modelled as a List ADT and implemented via an array (fast random access by index) or a linked list (convenient insertions/deletions at arbitrary positions).

How to Write an ADT Answer in Exams

  1. Start with a crisp definition: State that an ADT specifies data, valid operations, and behaviour independently of implementation.
  2. Contrast ADT vs. Data Structure: Give a short comparison (specification vs. implementation).
  3. Explain 2–3 standard ADTs: Clearly write the rule (such as LIFO or FIFO), list the core operations, and mention both array and linked-list implementations with a small numerical or real-life example.

Diagrams

abstract-data-types-adt - Diagram

abstract-data-types-adt - Diagram

Advertisement
Advertisement