Abstract Data Types (ADT)
Introduction
An Abstract Data Type defines a data type by its behavior (operations) rather than its implementation.
Definition
ADT: A type defined by operations, hiding representation.
C++ Code Example
class Stack {
int arr[100]; int top;
public:
void push(int x){ arr[++top]=x; }
int pop(){ return arr[top--]; }
};Important Questions
Short Questions
- Define ADT.
- Give examples of ADT.
- ADT vs data structure?
- Why use ADT?
Long Questions
- Explain ADT with stack example.
- Discuss benefits of ADT.
MCQ Practice
1. ADT is defined by:
- Operations/behavior
- Implementation
- Memory layout
- Compiler
Answer: Operations/behavior.
2. Stack is an:
- ADT
- Operator
- Keyword
- Macro
Answer: ADT.
3. ADT hides:
- Representation
- Operations
- Interface
- Name
Answer: Representation.
4. Which is an ADT?
- Queue
- int
- char
- float
Answer: Queue.
5. ADT promotes:
- Abstraction
- Speed only
- Memory only
- None
Answer: Abstraction.
Quick Revision
- ADT = behavior, not implementation.
- Examples: stack, queue, list.