Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Data Structures Cheat Sheet

1 of 2

https://www.clear.rice.edu/comp160/data_cheat.html

Data Structures Cheat Sheet


[Data Structures I] [Data Structures II] [Data Structures III] [Data Structures IV] [Data Structures Cheat Sheet]

add to
end

Array

O(n)

List<T>

best
case
O(1);
worst
case
O(n)

Collection<T>

best
case
O(1);
worst
case
O(n)

LinkedList<T>

O(1)

Stack<T>

best
case
O(1);
worst
case
O(n)

Queue<T>

best
case
O(1);
worst
case
O(n)

Dictionary<K,T>

best
case
O(1);
worst
case

remove
from
end

O(n)

O(1)

O(1)

O(1)

O(1)

insert at
middle

O(n)

O(n)

O(n)

O(1)

N/A

O(1)

N/A

O(1)

best
case
O(1);
worst
case

remove
from
middle

O(n)

O(n)

O(n)

O(1)

N/A

N/A

O(1)

Random
Access

O(1)

O(1)

O(1)

O(n)

N/A

N/A

O(1)*

In-order
Access

O(1)

O(1)

O(1)

O(1)

N/A

N/A

O(1)*

Search
for
specific
element

Notes

O(n)

Most efficient
use of
memory; use
in cases where
data size is
fixed.

O(n)

Implementation
is optimized for
speed. In
many cases,
List will be the
best choice.

O(n)

List is a better
choice, unless
publicly
exposed as
API.

O(n)

Many
operations are
fast, but watch
out for cache
coherency.

N/A

Shouldn't be
selected for
performance
reasons, but
algorithmic
ones.

N/A

Shouldn't be
selected for
performance
reasons, but
algorithmic
ones.

O(1)

Although
in-order
access time is
constant time,
it is usually
slower than
other
structures due

1/18/2017 3:40 PM

Data Structures Cheat Sheet

2 of 2

https://www.clear.rice.edu/comp160/data_cheat.html

O(n)

O(n)

to the
over-head of
looking up the
key.

1/18/2017 3:40 PM

You might also like