Arrays

What Are the Four Types of Data Structures?

There is no single official list of four data structure types. Learn the common ways courses group them, and how to answer when asked for four.

On this page
  1. The short answer: there is no single official list
  2. Primitive versus non-primitive
  3. Linear versus non-linear
  4. Static versus dynamic
  5. A simple table
  6. Answering this on an exam

The short answer: there is no single official list

There is no single official list of four types of data structures. Courses, textbooks, and lecture notes group data structures in different ways, and the names and boundaries vary. If your course gives you a list of four, use that list. If it does not, the safest answer is to name the grouping you are using and give an example for each group.

Primitive versus non-primitive

Primitive data types are the basic types a programming language provides, such as integers, floats, booleans, and characters. Non-primitive structures are built from those types. Lists, arrays, stacks, trees, and graphs are common examples of non-primitive structures in many courses.

This split is where primitive vs non primitive data types is usually discussed. Some sources place arrays among primitive structures, while others treat them as non-primitive, so check your course’s definition.

Linear versus non-linear

Linear structures keep their elements in a sequence, where each element has one predecessor and one successor. Arrays, linked lists, stacks, and queues are usually called linear.

Non-linear structures do not arrange elements in one sequence. Their elements connect in a hierarchy or in a network. Trees and graphs are the usual examples.

Static versus dynamic

A static structure has a fixed size that is set when it is created. A dynamic structure can grow or shrink while the program runs. A fixed-length array is static, while a resizable list is dynamic. This split is about memory and size, not about how the elements are organized.

A simple table

Structure Linear or non-linear Static or dynamic
Array (fixed size) Linear Static
Dynamic array or list Linear Dynamic
Linked list Linear Dynamic
Stack Linear Depends on the implementation
Queue Linear Depends on the implementation
Tree Non-linear Usually dynamic
Graph Non-linear Usually dynamic

The table is a rough guide. A stack or queue can be built on a fixed array or a dynamic structure, so the last column depends on the implementation.

Answering this on an exam

When a question asks for the types of data structures, state the grouping you are using and give one example for each category. For example, if you use linear and non-linear, you can name arrays and stacks as linear and trees as non-linear. A stack is usually taught through its operations, which you can read about in stack operations in data structure.

If you are not sure which grouping your teacher expects, mention the one from your notes and explain the criteria in a sentence. That shows understanding even when the labels differ.

The complete guide to arrays

Is an Array a Data Structure?
Read the guide

Keep exploring

Guides from other topics

All topics →