Past exam question: 2077 Chaitra (Regular), Q1
Open in the Padhaiko appQuestion
Briefly explain the statement "ADT provides extraction" with suitable example.
Solution
Meaning of "ADT Provides Abstraction": An Abstract Data Type (ADT) separates the logical specification (the interface of allowed operations and their behavior) from the physical implementation (how data is laid out in memory and how algorithms are coded). This principle is data abstraction (printed as "extraction" in the question paper):
- Information Hiding: Users interact only with well-defined public operations without seeing internal pointers, array bounds, or reallocation logic.
- Modularity & Interchangeability: The internal implementation can be swapped (e.g., array vs. linked list) without breaking client code that calls the ADT interface.
Example: Stack ADT:
- Logical Interface (What it does):
push(x),pop(),peek(),isEmpty(). Client code (such as postfix evaluation) only calls these operations assuming LIFO behavior. - Hidden Implementation (How it works): One implementation stores items in an array
items[MAX]with integer indextop; another stores dynamicNodestructs linked via pointers. Changing from array to linked list requires zero changes to the postfix evaluator.
Answer:
An ADT provides abstraction (misprinted as "extraction") by exposing only the logical data model and operation signatures (push, pop, peek for a Stack ADT) while hiding internal storage details (contiguous array vs. linked nodes), allowing implementations to change without affecting client programs.