Skip to main content

Data Structures Overview

Time and Space Complexity Overviews

Click on a tab below to see the worst or average case time complexities for access, search, insertion, and deletion operations for common data structures. The worst case tab includes space complexity details for each data structure. The last tab includes details about the best, average, and worst case time complexities for various array sorting algorithms as well as a column with space complexity details.

It is like that, but we need to know mores. Maintaining

O(n)O(n)
is not fun.

Data StructureAccessSearchInsertionDeletionSpaceRemark
ArrayO(1)\perfVeryGood{O}{1}O(n)\perfAverage{O}{n}O(n)\perfAverage{O}{n}O(n)\perfAverage{O}{n}O(n)\perfAverage{O}{n}tbd
StackO(n)\perfAverage{O}{n}O(n)\perfAverage{O}{n}O(1)\perfVeryGood{O}{1}O(1)\perfVeryGood{O}{1}O(n)\perfAverage{O}{n}tbd
QueueO(n)\perfAverage{O}{n}O(n)\perfAverage{O}{n}O(1)\perfVeryGood{O}{1}O(1)\perfVeryGood{O}{1}O(n)\perfAverage{O}{n}tbd
Singly-Linked ListO(n)\perfAverage{O}{n}O(n)\perfAverage{O}{n}O(1)\perfVeryGood{O}{1}O(1)\perfVeryGood{O}{1}O(n)\perfAverage{O}{n}tbd
Doubly-Linked ListO(n)\perfAverage{O}{n}O(n)\perfAverage{O}{n}O(1)\perfVeryGood{O}{1}O(1)\perfVeryGood{O}{1}O(n)\perfAverage{O}{n}tbd
Skip ListO(n)\perfAverage{O}{n}O(n)\perfAverage{O}{n}O(n)\perfAverage{O}{n}O(n)\perfAverage{O}{n}O(nlogn)\perfBad{O}{n\log n}tbd
Hash TableN/A\colorbox{gray}{N/A}O(n)\perfAverage{O}{n}O(n)\perfAverage{O}{n}O(n)\perfAverage{O}{n}O(n)\perfAverage{O}{n}tbd
Binary Search TreeO(n)\perfAverage{O}{n}O(n)\perfAverage{O}{n}O(n)\perfAverage{O}{n}O(n)\perfAverage{O}{n}O(n)\perfAverage{O}{n}tbd
Cartesian TreeN/A\colorbox{gray}{N/A}O(n)\perfAverage{O}{n}O(n)\perfAverage{O}{n}O(n)\perfAverage{O}{n}O(n)\perfAverage{O}{n}tbd
B-TreeO(logn)\perfGood{O}{\log n}O(logn)\perfGood{O}{\log n}O(logn)\perfGood{O}{\log n}O(logn)\perfGood{O}{\log n}O(n)\perfAverage{O}{n}tbd
Red-Black TreeO(logn)\perfGood{O}{\log n}O(logn)\perfGood{O}{\log n}O(logn)\perfGood{O}{\log n}O(logn)\perfGood{O}{\log n}O(n)\perfAverage{O}{n}tbd
Splay TreeN/A\colorbox{gray}{N/A}O(logn)\perfGood{O}{\log n}O(logn)\perfGood{O}{\log n}O(logn)\perfGood{O}{\log n}O(n)\perfAverage{O}{n}tbd
AVL TreeO(logn)\perfGood{O}{\log n}O(logn)\perfGood{O}{\log n}O(logn)\perfGood{O}{\log n}O(logn)\perfGood{O}{\log n}O(n)\perfAverage{O}{n}tbd
KD TreeO(n)\perfAverage{O}{n}O(n)\perfAverage{O}{n}O(n)\perfAverage{O}{n}O(n)\perfAverage{O}{n}O(n)\perfAverage{O}{n}tbd

What is a data structure?

It is like that, but we need to know mores. Maintaining

more footnotes
is not fun.

A data structure, as its name implies, is a way of structuring data. Since we are dealing with computers, we are ultimately talking about a way of specifically structuring data inside random-access memory (RAM). As the Wiki article notes:

In computer science, a data structure is a data organization, management, and storage format that is usually chosen for efficient access to data. More precisely, a data structure is a collection of data values, the relationships among them, and the functions or operations that can be applied to the data (i.e., it is an algebraic structure about data).