---
title: "Define ADT with example"
subject: "Data Structure and Algorithm"
chapter: 1
key: "semester_4/data_structure_and_algorithm:adt-with-example"
source: https://www.bctengineer.com/q/semester_4/data_structure_and_algorithm/adt-with-example
site: BCT Engineering
---

# Define ADT with example

Data Structure and Algorithm · Chapter 1: Concept of data structure

- Asked in: 2070 Bhadra, 4 marks; 2069 Poush, 4 marks (asked 2 times)
- Video: [What is Abstract Data Types(ADT) in Data Structures ? | with Example](https://www.youtube.com/watch?v=n0e27Cpc88E) — Simple Snippets
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_4/data_structure_and_algorithm/adt-with-example
- Whole chapter: https://www.bctengineer.com/md/semester_4/data_structure_and_algorithm/chapter-1

## Question

Define ADT (abstract data type) with a suitable example.

## Short answer

An abstract data type (ADT) is a mathematical model defined by its values and allowed operations, hiding implementation. For example, a RATIONAL ADT provides makerational and add operations without revealing if it uses an array or struct.

## Answer

An **abstract data type (ADT)** is a mathematical model of a data type that is defined by its **values** and the **operations** allowed on them, without saying how they are stored or coded. The user sees only *what* the type does; *how* it is done (array, linked list, etc.) stays hidden. In Tenenbaum's style an ADT has two parts: a **value definition** and an **operator definition**.

#### Example: RATIONAL numbers

```text
/* Value definition */
abstract typedef <integer, integer> RATIONAL;
condition RATIONAL[1] != 0;      /* denominator never zero */

/* Operator definition */
abstract RATIONAL makerational(a, b)
   int a, b;
   precondition  b != 0;
   postcondition makerational[0] == a  and  makerational[1] == b;

abstract RATIONAL add(a, b)
   RATIONAL a, b;
   postcondition add[1] == a[1] * b[1]
             and add[0] == a[0] * b[1] + b[0] * a[1];
```
Here the user calls `makerational(1, 2)` and `add(x, y)` without knowing whether a rational is kept as an array of two integers or a struct. Another common example is the **stack** ADT with `push`, `pop`, `empty`.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. An abstract data type is defined by which two things?
   A. Its array size and pointer type
   B. Its memory layout and the language used
   C. Its values and the operations allowed on them
   D. Its compile time and run time
   Answer: C. An ADT is a mathematical model given by values and operations, not by how it is stored. (Key point: What an ADT defines)

2. What does a user of the RATIONAL ADT need to know?
   A. Whether it is stored as an array or a struct
   B. Only what operations like makerational and add do
   C. The memory address of each rational
   D. The machine instructions used for addition
   Answer: B. The user sees only what the type does; how it is implemented stays hidden. (Key point: Implementation hiding)

3. In Tenenbaum's style, an ADT specification has which two parts?
   A. Header definition and body definition
   B. Input definition and output definition
   C. Static definition and dynamic definition
   D. Value definition and operator definition
   Answer: D. The value definition gives the values and conditions; the operator definition gives the operations. (Key point: Two parts of ADT)

4. In makerational(a, b), what is the precondition?
   A. b != 0
   B. a != 0
   C. a == b
   D. b == 1
   Answer: A. A rational's denominator must never be zero, so the precondition is b != 0. (Key point: Precondition)

## Close variants set in other exams

- [Data type and ADT definition](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Adata-type-and-adt) — Data Structure and Algorithm, chapter 1, asked 3×

## Related in Data Structure and Algorithm

- [Define data structure; explain ADT](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Adata-structure-and-adt) — Data Structure and Algorithm, chapter 1
- [ADT versus data structure](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Aadt-vs-data-structure) — Data Structure and Algorithm, chapter 1
- [Types of data structures; ADT example](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Adata-structure-types-adt-example) — Data Structure and Algorithm, chapter 1
- [ADT of linked list](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Aadt-linked-list-definition) — Data Structure and Algorithm, chapter 1
- [ADT of stack: value and operator definition](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Aadt-stack-value-operator) — Data Structure and Algorithm, chapter 1

## Related in other subjects

- [Polygon abstract class with Area()](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Apolygon-abstract-area) — Object Oriented Programming, chapter 7
