
Learn Computer Science
Developing a more interesting World
"Computer science is no more about computers than astronomy is about telescopes."
Edsger Dijkstra
Free beginner - intermediate level computer science tutorials
Abstract Data Types
Tutoring > Data Structures > Abstract Data Types
An abstract data type (or ADT) is:
-
a type
-
with associated operations
-
whose representation is hidden
They are mathematical models for representing a class of data structure.
The data structure will have similar behaviour to other data structures of the same type.

What is a type?
A type (or data type) is a classification identifying one of various types of data that determines the possible values of that type.
Examples of types in computer science:
Integer - a whole number.
Character - a single alphanumeric or punctuation character.
Boolean - can be only either True or False.

Hide the representation - abstraction
When we use an ADT, we don't see what is going on behind the scenes. This is what the abstract part means.
Abstraction is the separation of ideas from instances of those ideas at work. This enables people to work on complex problems without the need to follow and understand every tiny detail and process going on.
Control abstraction is the abstraction of actions while data abstraction is that of data structures.

Associated operations?
Operations on data types are what define them. They are a set of procedures or "functions" that do something to the ADT.
For example, an abstract integer stack has three operations that can be performed on it, push, pop and peek. More on this in the Arrays, Lists, Stacks and Queues page.
An operation in simple terms is when a result is specified by rules. For example, in addition, the result is the sum of two or more numbers:
2 + 4 = 6
This is an addition operation. The result is 6, which comes from adding the 2 and 4.

Algorithms
An algorithm is a step by step procedure for calculating something. It is a set of instructions that you can input data into and expect a result based on what the algorithm is for.
When we talk about an algorithm, we are talking about a general formula to achieve something, NOT a particular instance of an implementation of the algorithm.