A data type is an abstract interface that defines a set of possible values along with their allowed behavior. It’s a protocol relating data structures and algorithms .
A data structure is a concrete implementation of a data type (e.g. in a programming language, or in physical memory).
Confusingly, these terms are often used interchangeably.1
Primitive data types
In a programming language, a primitive data type is a basic type from which all other types are constructed. Common primitive types include:
- Numerics (Integer, float, etc.)
- Pointer (memory address)
A data structure is a format for physically storing information such that it can be efficiently stored, retrieved, and processed by a computer.
Some data types are so fundamental, and their implementations so well known, that they are often simply referred to as data structures.
A composite data type is a type that can be composed using a language’s primitive data types, along with other composite types. These types are the building blocks of all other more complex types:
- Records (objects, structs)
- Arrays 2
Additional well-known types that are referred to as data structures include:
Abstract data types
Formally, an abstract data type (ADT) is a mathematical model defining the possible values and behaviors of a data type.
More commonly, an ADT simply refers to data types that are more abstract than the preceding listed types. ADTs are usually implemented using one or more well-known data structures:
|Type||Common underlying data structures|
|List||Array, linked list|
|Stack||Array, linked list|
|Map||Hash table, binary tree|
|Set||Hash table, binary tree|