Skip to content

Data types

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 .

The relationship between data types, data structures, and algorithms.

(original)

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:

Data structures

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:

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
Queue Linked list
Deque Linked list
Priority queue Heap
Map Hash table, binary tree
Set Hash table, binary tree

  1. This gets confusing if you are a pedant trying to learn the subject from fundamentals (like myself). ↩︎

  2. A string type can be implemented as an array of char types. ↩︎