Data Structures – What Do Programmers Mean by Data Structures?

data structuresdefinitionterminology

When programmers talk about "data structures", are they only talking about abstract data types like lists, trees, hashes, graphs, etc.?

Or does that term include any structure that holds data, such as composite types (class objects, structs, enums, etc.) and primitive types (boolean, int, char, etc.)?

I've only ever heard programmers use the term to reference complex data structures or abstract data types, however the Wikipedia article that provides a list of data structures includes both composite types and primitive types in the definition, which is not what I expected (even though it does make sense).

When looking around online I see other places that refer to the term "data structure" in the programming sense as only referring to abstract data types, such as this lecture from Stony Brook University's Department of Computer Science which states

A data structure is an actual implementation of a particular abstract data type.

or this wikibook on data structures, which uses the term in sentences like this:

Because data structures are higher-level abstractions, they present to
us operations on groups of data, such as adding an item to a list, or
looking up the highest-priority item in a queue

So why do I only ever hear programmers referring to complex data structures or abstract data types when they use the term "data structure"? Do programmers have a different definition for the term than the dictionary definition?

Best Answer

The generic definition of "data structure" is anything that can hold your data in a structured way, so yes this would include composite types and primitive types in addition to abstract data types. For example, a string is a data structure as it can hold a sequence of characters in a structured way.

However, the term also has another meaning to programmers.

Since the term "data structures" is so broad, developers usually use a more specific term to identify what they are talking about, such as class or data object or primitive type, and the specific term used for most complex or abstract data types is "data structure"

This is why you hear "data structure" most frequently being used for abstract data types like Arrays, Lists, Trees and Hashtables, and not for things like primitive data types